Structured BoM - all Levels

Structured BoM - all Levels

MarkusGreifeneder3360
Advocate Advocate
4,009 Views
6 Replies
Message 1 of 7

Structured BoM - all Levels

MarkusGreifeneder3360
Advocate
Advocate

Hi,

is it possible to export the Structured BoM over all levels with correct Position-Numbers from Inventor?

 

for e.g.:

 

Assembly 068487 has Pos. 1, 2, 10

When placing this assembly in top assembly, the Structured BoM over all levels says:

Pos. 1.1, 1.2, 1.3

should be

Pos. 1.1, 1.2, 1.10

 

Why is this behaviour?

How can I export it as needed?

 

BoM.jpg

Accepted solutions (1)
4,010 Views
6 Replies
Replies (6)
Message 2 of 7

johnsonshiue
Community Manager
Community Manager

Hi Marcus,

 

This is because the item numbers for first level are different than all levels. The item numbers are stored in each iam file (BOM). There isn't inheritance between them.

Many thanks!



Johnson Shiue ([email protected])
Software Test Engineer
0 Likes
Message 3 of 7

cadman777
Advisor
Advisor

I encountered that limitation early in my use of Inventor and decided to make my own Mark No.

It is a composite number consisting of Custom iProperties: "SHAPE" + "MARK", or whatever you need.

Then I use the Inventor's native "Stock Number" to construct the part's Mark No: =<SHAPE><MARK>, or just =<MARK>. which shows up as a letter & number or just a number (depends on type of project). This occurs as an iProperty in all my ContentCenter parts, so the drawing PartsList automatically populates.

 

Example: Pipes are "P01" (etc.)

                 Beams are "B01" (etc.)

                 Weldments are "W01" (etc.)

                 Concrete is "C01" (etc.)

You can make it anything you want, with as many place holders (iProperties) that you want.

 

Or, if you want to make a string of numbers that shows model structure, you can use iLogic to string together all the "MARK" numbers, separated by a "." (dot). But you have to be sure you don't over-write a number that you already created of a part that exists in a previous sub-assembly. That's where it gets tricky, and you have to decide on what rules you will use to do numbering. Numbering is never easy if you are in a complex modeling environment.

 

I do all my numbering manually. But if you can make an iLogic rule, maybe you can automate the numbering process?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 4 of 7

MarkusGreifeneder3360
Advocate
Advocate
Accepted solution

Hi, for all who have the same problem.

I found following iLogic-rule

 

 

Sub Main()
Dim sErrMsgBadDoc As String
sErrMsgBadDoc = "This macro requires active assembly document."
If ThisApplication.ActiveDocument Is Nothing Then
    MessageBox.Show(sErrMsgBadDoc)
    Exit Sub
End If

If Not TypeOf ThisApplication.ActiveDocument Is AssemblyDocument Then
    MessageBox.Show(sErrMsgBadDoc)
    Exit Sub
End If

Dim oTxnMgr As TransactionManager = ThisApplication.TransactionManager
Dim oTxn As Transaction = oTxnMgr.StartTransaction(ThisApplication.ActiveDocument, "BOM Sync")

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM = oDoc.ComponentDefinition.BOM

oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
oBOM.StructuredViewDelimiter = "."

' Find structured view
Dim oStructView As BOMView = oBOM.BOMViews("Structured")

If oStructView Is Nothing Then
    ' No struct view even if enabled? Probably because of LOD
    MessageBox.Show("Cannot get structured BOM view, make sure Master LOD is active")
	oTxn.End
    Exit Sub
End If

' Now get rows and update item numbers for sub assemblies recursively
Dim oRow As BOMRow
For Each oRow In oStructView.BOMRows
    If Not oRow.ChildRows Is Nothing Then
        UpdateItemNumbers(oRow, oBOM.StructuredViewDelimiter)
    End If
Next oRow

oStructView.Sort("Item")

MessageBox.Show("BOM item numbers have been synced", "BOM Sync")
oTxn.End
End Sub

Sub UpdateItemNumbers(oRow1 As BOMRow, sDelim As String)
' assembly row expected as input
If oRow1.ChildRows Is Nothing Then
    Exit Sub
End If

' get sub BOM and its structured view
Dim oBOM2 As BOM = oRow1.ComponentDefinitions(1).BOM
If oBOM2.StructuredViewEnabled = False Then
	Try
		oBOM2.StructuredViewEnabled = True
	Catch
		'MessageBox.Show("Could not enable BOM on " & oRow1.ComponentDefinitions.Item(1).Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value)
		GoTo NextRow:
	End Try
End If
Dim oStructView2 As BOMView = oBOM2.BOMViews("Structured")

' No structured view in this sub bom? Nothing to do.
If oStructView2 Is Nothing Then
    Exit Sub
End If

' Now iterate sub rows and match them to rows in sub bom. Transfer item number if needed
Dim oRow2 As BOMRow
For Each oRow2 In oRow1.ChildRows
	'MessageBox.Show(oRow2.ComponentDefinitions.Item(1).Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value)
    ' Find this row in sub bom
    Dim oRow3 As BOMRow = FindRow(oStructView2, oRow2)

    If Not oRow3 Is Nothing Then
        If Not oRow2.ChildRows Is Nothing Then
            ' Workaround for assembly renumbering to preserve parent numbers
            ModifyAssemblyItemNumber(oRow2, oRow3, sDelim)
        ElseIf TypeOf oRow2.ComponentDefinitions.Item(1) Is VirtualComponentDefinition Then
			'MessageBox.Show(oRow2.ComponentDefinitions(1).PropertySets.Item("Design Tracking Properties").Item("Part Number").Value & vbCr & oRow3.ItemNumber)
			Dim oItem As String' = VirtualItem(oRow3)
			oItem = oRow3.ItemNumber
			oRow2.ItemNumber = oItem
		Else
            oRow2.ItemNumber = oRow3.ItemNumber
        End If
    End If
    'Recurse
    If Not oRow2.ChildRows Is Nothing Then
        UpdateItemNumbers(oRow2, sDelim)
    End If
Next oRow2
NextRow:
End Sub

' compares two BOM rows from different BOMs if they refer to same components
Function MatchRows(oRow1 As BOMRow, oRow2 As BOMRow) As Boolean
If oRow1.ComponentDefinitions.Count <> oRow2.ComponentDefinitions.Count Then
    MatchRows = False
    Exit Function
End If
Dim i As Integer
For i = 1 To oRow1.ComponentDefinitions.Count
    If oRow1.ComponentDefinitions(i).Document.FullDocumentName <> oRow2.ComponentDefinitions(i).Document.FullDocumentName Then
        MatchRows = False
        Exit Function
    End If
Next i
'Fix for virtual components getting all the same item number
If TypeOf oRow1.ComponentDefinitions(1) Is VirtualComponentDefinition Then
	If oRow1.ComponentDefinitions(1).PropertySets.Item("Design Tracking Properties").Item("Part Number") IsNot oRow2.ComponentDefinitions(1).PropertySets.Item("Design Tracking Properties").Item("Part Number")
		MatchRows = False
		Exit Function
	End If
End If
MatchRows = True
End Function

' finds BOM row in the specified BOM view which refer to same component as input row
' no recursion, first level search only
Function FindRow(oBOMView2 As BOMView, oRow2 As BOMRow) As BOMRow
Dim oRow As BOMRow
For Each oRow In oBOMView2.BOMRows
    If MatchRows(oRow2, oRow) Then
        FindRow = oRow
        Exit For
    End If
Next oRow
End Function

' Modyfing item numbers for assembly works differently than for parts.
' For part, only last part of the number is modified (for example "3.4", when set to "10" will change to "3.10").
' For assemblies, override is set which replaces everything (for example "3.4", when set to "10" will change to "10").
' Looks like a defect in API, it should be consistent. Ideally, API should provide both ways of modifying the part number.
' Workaround it to preserve the inherited part of the number (but it won't update when parent's number changes because of
' override.
Sub ModifyAssemblyItemNumber(oDestRow As BOMRow, oSrcRow As BOMRow, sDelim As String)
' source item number is always 1st level only
' get last part of current item number, use current delimiter
Dim sItem As String
sItem = oDestRow.Parent.ItemNumber
sItem = sItem & sDelim & oSrcRow.ItemNumber
oDestRow.ItemNumber = sItem
End Sub

, solving the problem 

Message 5 of 7

bionorica2015
Enthusiast
Enthusiast

Hello

Please answer if You can to question in this link please. Because I see You are experienced user of Inventor

https://forums.autodesk.com/t5/inventor-forum/inventor-bom-quantity-column-order-customize/td-p/1097...

0 Likes
Message 6 of 7

dusan.naus.trz
Advisor
Advisor

Hi,
I wonder when there will be a link between the parts to what the user asks in the post? When will there be an inheritance between them?

I have been thinking about various things for a long time.
Mechanical Engineer design various machines and equipment, I mean the bigger machines in countries like USA, Japan, Germany, Czech Republic and many other countries, they have very similar drawing documentation, they all need a certain type of data. When I read the forum and search for information, many people ask the same thing. Bill Of Materials has been working pretty much the same since Inventor 6 (2002), with some very small functionality being added occasionally. I think it would be appropriate to make the Bill Of Materials and other things much better. Just to hint lightly, I would take all the code from the forum and put it in the new version. 🙂