- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Autodesk Inventor Professional Certified 2014