- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi , I'm new with ilogic code. I'm recently working on a code to automatic sort the Partslist inside a IDW.
The Partslist doesn't have a mass column. but in order to sort it i need the weight for each row. so i write following code.
SyntaxEditor Code Snippet
On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
Dim oRow As PartsListRow
Dim oAssyDoc As AssemblyDocument
Dim Mass As Double
For Each oRow In oPartsList1.PartsListRows
MessageBox.Show(oRow.ReferencedFiles.Item(1).DocumentType)
oAssyDoc = oRow.ReferencedFiles.Item(1)
oAssyDoc.ComponentDefinition.MassProperties.Accuracy = k_Medium
Mass = oAssyDoc.ComponentDefinition.MassProperties.Mass
MessageBox.Show(Mass)
Next
I can see the referenced file type 12290 (ipt) and 12291 (iam). but the weight is always 0.
can anyone help me with that ?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dim Mass As inventor.massproperties
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@bradeneuropeArthur, thanks for your reply.
I have tried to declare the mass, but it still not working.
I solved the problem by adding an column of Mass in the Partslist and deleted it afterwards.
I checked the ReferencedFiles Property (it is a hidden one) under the PartsListRow using the Object Browser in VBA environment.
and it is ReferencedFileDescriptors Type and only contain Application , Count, Item, ItemByName, Type. So there isn't Mass Property or anything else like the Normal Document file.
Probably that's why my code doesn't work.
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks @dgreatice, you are the best.
I was trying to do the same thing, but wasn't success. i thought it just stop at ReferencedFiles
Now i understand that the property chains are
PartsListRows.Partslists.ReferencedFiles.Item.ReferencedDocument.ComponentDeinition.MassProperty.Mass
Thanks