List all ItemNumbers, in all levels.

List all ItemNumbers, in all levels.

Anonymous
Not applicable
422 Views
1 Reply
Message 1 of 2

List all ItemNumbers, in all levels.

Anonymous
Not applicable

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

 

0 Likes
Accepted solutions (1)
423 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

You've just got to dig deeper.  Under your For Each oBOMRow line, check the oBOMRow.ChildRows.Count to see if it is greater than zero.

You could also check the oBOMRow.ReferencedFileDescriptor.ReferencedFileType, to see if it is a Part or Assembly.

Or you could do this a different way by:

Dim oRowDoc As Document = oBOMRow.ComponentDefinitions.Item(1).Document

If oRowDoc.DocumentType =

Keep in mind that BOM rows can also be "Merged", "Promoted", or "RolledUp", too.

You may need to check for these, if you have any of that going on within your BOM.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes