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

Hi @ober2558 . The dMassCC parameter (line 6) is the total mass of all components from the content center.

Sub Main()
	Dim oDoc As Document = ThisDoc.Document
	If Not TypeOf oDoc Is AssemblyDocument Then Exit Sub
	Dim oAsmDoc As AssemblyDocument = oDoc
	Dim oOccs As ComponentOccurrences = oAsmDoc.ComponentDefinition.Occurrences
	Dim dMassCC As Double
	For Each oRefDoc As Document In oAsmDoc.AllReferencedDocuments
		If TypeOf oRefDoc Is AssemblyDocument Then Continue For
		Dim iQTy As Integer = oOccs.AllReferencedOccurrences(oRefDoc).Count
		If iQTy = 0 Then Continue For
		If Not oRefDoc.ComponentDefinition.IsContentMember Then Continue For
		dMassCC += oRefDoc.ComponentDefinition.MassProperties.Mass * iQTy
	Next
	MessageBox.Show(dMassCC & " kg")
End Sub

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature