Message 1 of 4

Not applicable
10-30-2017
04:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I modified a code for BOM qty across all parts. The previous code only works with "Parts only"...
The modified code works on the Structured BOM.
That said it does not go through all sub assemblies "levels".
Can some one help me so it runs on all levels?
Thanks,
Josh
Inventor 2017
SyntaxEditor Code Snippet
doc = ThisDoc.Document Dim oAssyDef As AssemblyComponentDefinition = doc.ComponentDefinition Dim oBOM As BOM = oAssyDef.BOM oBOM.StructuredViewEnabled = True Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured") Dim oBOMRow As BOMRow For Each oBOMRow In oBOMView.BOMRows 'Set a reference to the primary ComponentDefinition of the row Dim oCompDef As ComponentDefinition oCompDef = oBOMRow.ComponentDefinitions.Item(1) Dim CompFullDocumentName As String = oCompDef.Document.FullDocumentName Dim CompFileNameOnly As String Dim index As Integer = CompFullDocumentName.lastindexof("\") CompFileNameOnly = CompFullDocumentName.substring(index+1) 'MessageBox.Show(CompFileNameOnly) Dim Qty As String Qty = oBOMRow.TotalQuantity iProperties.Value(CompFileNameOnly, "Custom", "PartQty") = Qty iProperties.Value(CompFileNameOnly, "Custom", "SO") =iProperties.Value("Custom", "SO") Next
Solved! Go to Solution.