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

Hi @ober2558,

 

You could do as folowing : 

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
			
		Dim qty As Integer = occs.AllReferencedOccurrences(refDoc).Count

		If Not refDoc.ComponentDefinition.IsContentMember Then Continue For
		
		Dim list As New List(Of String)
		list.Add("ISO 4032 M12")
		list.Add("ISO 4032 M10")
		list.Add("ISO 4032 M16")
		
		If list.Contains(refDoc.DisplayName) = False Then Continue For	
			
		mass += refDoc.ComponentDefinition.MassProperties.Mass * qty
		
	Next
	
	MessageBox.Show(mass & " kg")
	
End Sub

Simply change the names in the list.add(name) method.

You can add more lines if desired.

 

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