Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
394 Views, 1 Reply

List all ItemNumbers, in all levels.

Hi all,

 

I'm trying to list all (Structured) ItemNumbers in all levels/subassemblies just like inventor does:

BOMStructured.gif

however using my code I only get the first level (so 4.1 is not added to the array).

This is my code:

Public Sub GetPtLevels()
   Dim LevelList As List(Of String)
        objapprenticeServerApp = Marshal.GetActiveObject("Inventor.Application")

        Dim doc As Document = objapprenticeServerApp.ActiveDocument
        Dim oAssyDef As AssemblyComponentDefinition = doc.ComponentDefinition
        Dim oBOM As BOM = oAssyDef.BOM
        oBOM.StructuredViewFirstLevelOnly = False

        Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured")
        Dim oBOMRow As BOMRow

        For Each oBOMRow In oBOMView.BOMRows
            LevelList.Add(oBOMRow.ItemNumber)
        Next
End Sub