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

Hi,

 

try this:

 

Public Sub GetMassFromPartList()
    Dim oApp As Application
    Dim oDD As DrawingDocument
    Dim oSht As Sheet
    Dim oPL As PartsList
    Dim oRow As PartsListRow
    Dim oDoc As Document
    Dim oPD As PartDocument
    Dim oAD As AssemblyDocument
    Dim oPCD As PartComponentDefinition
    Dim oACD As AssemblyComponentDefinition
   
    Set oApp = ThisApplication
    Set oDD = oApp.ActiveDocument
    Set oSht = oDD.ActiveSheet
    Set oPL = oSht.PartsLists.Item(1)
   
    For Each oRow In oPL.PartsListRows
        Set oReffDoc = oRow.ReferencedFiles.Item(1)
        Set oDoc = oReffDoc.ReferencedDocument
        If oDoc.DocumentType = kAssemblyDocumentObject Then
            Set oAD = oDoc
            Set oACD = oAD.ComponentDefinition
            MsgBox (Round(oACD.MassProperties.Mass, 2) & " Kg")
        ElseIf oDoc.DocumentType = kPartDocumentObject Then
            Set oPD = oDoc
            Set oPCD = oPD.ComponentDefinition
            MsgBox (Round(oPCD.MassProperties.Mass, 2) & " Kg")
        End If
    Next
   
   
End Sub

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014