Looping Structured bill of material skips merged rows

Looping Structured bill of material skips merged rows

Anonymous
Not applicable
462 Views
2 Replies
Message 1 of 3

Looping Structured bill of material skips merged rows

Anonymous
Not applicable

Greetings Inventor masters,

 

I am currently writing an add-in that numbers the BOM, The only issue that i am encoutering right now is that i use the structured view as a base with row merge activated. The problem with this is that when i iterate through the BOM only 1 part of the merged rows gets numbered. I want all the rows that are merged to get the same number, but i don't really know how to check if the current row is a merged one. Any ideas widely appreciated.

 

Rob Rombouts

Inventor Add-in progreammer newbie

0 Likes
Accepted solutions (1)
463 Views
2 Replies
Replies (2)
Message 2 of 3

frederic.vandenplas
Collaborator
Collaborator
Accepted solution

Hi, This should work (vba)

Sub test()

Dim oIamDoc As AssemblyDocument
Set oIamDoc = ThisApplication.ActiveDocument
Dim oIamCompDef As AssemblyComponentDefinition
Set oIamCompDef = oIamDoc.ComponentDefinition

Dim oBom As BOM
Set oBom = oIamCompDef.BOM
oBom.PartsOnlyViewEnabled = True

Dim oBomView As BOMView
Set oBomView = oBom.BOMViews.Item("Structured")
Dim oBOMRows As BOMRowsEnumerator
Set oBOMRows = oBomView.BOMRows
Dim i As Integer
For i = 1 To oBOMRows.Count
Debug.Print oBOMRows.Item(i).ComponentDefinitions.Count ' if more then one, it's merged
Dim j As Integer
For j = 1 To oBOMRows.Item(i).ComponentDefinitions.Count
Debug.Print oBOMRows.Item(i).ComponentDefinitions.Item(j).Document.FullFileName
Next j
Next i
        
End Sub

Output:

 1 
C:\Users\Frederic\Componenten\\Kantschaar\Kantschaar rechts.iam
 2 
C:\Users\Frederic\Componenten\Kantschaar\Kantschaar links.iam
C:\Users\Frederic\Componenten\Kantschaar\Kantschaar links1.iam

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 3 of 3

Anonymous
Not applicable

Did the trick, thanks again Frederic.

0 Likes