Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
FINET_Laurent
in reply to: ober2558

@ober2558,

 

What about this one? I used your exemple. The code will check if the document name contains the input words you specify in the list :

Sub Main
	Dim doc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim occs As ComponentOccurrences = doc.ComponentDefinition.Occurrences
	Dim mass As Double
	
	For Each refDoc As Document In doc.AllReferencedDocuments
		If TypeOf refDoc Is AssemblyDocument Then Continue For
		If Not refDoc.ComponentDefinition.IsContentMember Then Continue For

		Dim list As New List(Of String)
		list.Add("X 25-25 Profile")

		Dim check As Boolean = False
		
		For Each s As String In list
			If refDoc.DisplayName.Contains(s) Then 
				check = True
				Exit For 
				
			End If
		Next
		
		If check = False Then Continue For
						
		Dim qty As Integer = occs.AllReferencedOccurrences(refDoc).Count	
		mass += refDoc.ComponentDefinition.MassProperties.Mass * qty
		
	Next
	
	MessageBox.Show(mass & " kg")
	
End Sub

Kind regards,

FINET L. 

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill