Renumber BOM & Sort by Item

Renumber BOM & Sort by Item

Anonymous
Not applicable
955 Views
4 Replies
Message 1 of 5

Renumber BOM & Sort by Item

Anonymous
Not applicable

Hey guys I'm starting to learn iLogic and I've run into an issue that I know is possible, but nothing I research is helping. Basically, I made an assembly with iLogic rules to set certain values and suppress or un-suppress parts based on options picked in the iLogic form and everything is working beautifully. But now I need to renumber and sort the parts in the BOM from the assembly and have that update the parts list in the drawing as well. Can anybody help with this?

0 Likes
956 Views
4 Replies
Replies (4)
Message 2 of 5

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous ,

 

Would it be acceptable to sort and renumber the parts list and push those changes back to the BOM, if so here is an example:

https://inventortrenches.blogspot.com/2011/02/ilogic-code-for-parts-lists-title.html

 

You would just un-comment the Renumber and SaveItemOveridesToBOM lines provided in that example to do those things.

 

edit:

also here is an example of sorting/renumbering the BOM from the assembly:

https://reghasell.blogspot.com/2012/05/i-have-been-struggling-for-about-week.html

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 3 of 5

Anonymous
Not applicable

The second link looks exactly what i want to do, but it's telling me a parameter is incorrect. Can representations affect this?

0 Likes
Message 4 of 5

rhasell
Advisor
Advisor

Hi

The code is referencing a custom entry of "TYPE" Change that to your own BOM entries, or remove it.

 

Below is the updated code, (I don't use it much any more, I use the Parts List Sort)

'Revised 03/2019
'This cut out a few mouse clicks.

' Set a reference to the assembly document.
' This assumes an assembly document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

' Set a reference to the BOM
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM

' Make sure that the parts only view is enabled.
oBOM.StructuredViewFirstLevelOnly = False ' Display All levels
oBOM.StructuredViewEnabled = True
oBOM.PartsOnlyViewEnabled = True
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")

' Set a reference to the "Parts Only" BOMView
Dim oPartBOMView As BOMView
oPartBOMView = oBOM.BOMViews.Item("Parts Only")

Call oStructuredBOMView.Sort("BOM Structure", True, "Stock Number", True)
oPartBOMView.Sort("BOM Structure", True, "Stock Number", True)
MessageBox.Show("Done", "Sort BOM")

''Re-Number the BOM
Call oPartBOMView.Renumber(1, 1)
Call oStructuredBOMView.Renumber(1, 1)
Reg
2026.1
0 Likes
Message 5 of 5

rhasell
Advisor
Advisor

Hi

 

This is actually the real code that I use now days, it sorts by item, but does not renumber. (That's done in the drawing)

'Revised 03/2019
'This will Sort the BOM by Item Number only
'As the BOM is controlled by the Parts List, and I just want to make viewing easier
'This cut out a few mouse clicks.

' Set a reference to the assembly document.
' This assumes an assembly document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

' Set a reference to the BOM
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM

' Make sure that the parts only view is enabled.
oBOM.StructuredViewFirstLevelOnly = False ' Display All levels
oBOM.StructuredViewEnabled = True
oBOM.PartsOnlyViewEnabled = True
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")

' Set a reference to the "Parts Only" BOMView
Dim oPartBOMView As BOMView
oPartBOMView = oBOM.BOMViews.Item("Parts Only")

'Call oStructuredBOMView.Sort("BOM Structure", True, "TYPE", True, "Stock Number", True) ' Old, left for reference
Call oStructuredBOMView.Sort("Item", True)
Call oPartBOMView.Sort("Item", True)
'oPartBOMView.Sort("BOM Structure",True ,"TYPE",True ,"Stock Number",True) 'Old, Left for reference
MessageBox.Show("Done", "Sort BOM")

'''The following is not needed anymore
''Re-Number the BOM
'Call oPartBOMView.Renumber(1, 1)
'Call oStructuredBOMView.Renumber(1, 1)

Reg
2026.1
0 Likes