How to read item number as per structured view

abilabib
Advocate
Advocate

How to read item number as per structured view

abilabib
Advocate
Advocate

I'm try for read item number like a picture below and wanna get the data structure as per Structured View.

But I can't. Because the program read the ItemNumber as per Model data or Hierarchy in object history. 

I wanna the data like this:

1
1.1
1.2
1.3
1.4
1.5
2
2.1
2.2
2.3
3
3.1
3.2
4
5
6

 

But I get actual data like this :

1
1.1
1.2
1.3
1.4
1.5
4
2
2.1
2.2
2.3
5
6
3
3.1
3.2

Here's the code :

 

Sub ListBomItems()
        Dim asm As AssemblyDocument
        asm = invApp.ActiveDocument

        Dim b As BOM
        b = asm.ComponentDefinition.BOM

        b.StructuredViewEnabled = True

        Dim bv As BOMView
        bv = b.BOMViews("Structured")

        Call ListItems(bv.BOMRows, 0)
    End Sub

    Sub ListItems(rows As BOMRowsEnumerator, indent As Integer)
        Dim row As BOMRow
        For Each row In rows
            Debug.Print(row.ItemNumber.ToString)
            If Not row.ChildRows Is Nothing Then
                Call ListItems(row.ChildRows, indent + 2)
            End If
        Next
    End Sub

Is there way for rearrange data structure in Model Data / Hierarchy model ?

 

 

 

BOM Structured.jpg

0 Likes
Reply
Accepted solutions (2)
2,163 Views
21 Replies
Replies (21)

chandra.shekar.g
Autodesk Support
Autodesk Support

@abilabib,

 

 

It is nice to hear that your program is completed successfully 🙂

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

tonythm
Advocate
Advocate

Hello @abilabib @chandra.shekar.g 

 

Can you share with me the vba code completed?

I need it to refer to the Structure - first level.

I am using excel to assign renumber according to itemnumber in bomrow. If you know please help me.

 

Thank you.

0 Likes