Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
rhasell
in reply to: martinhoos

Hi

 

In my experience, sorting the BOM from the Assembly is inefficient, you can only sort with one filter (I know that you are supposed to sort with more than one, but it does not work as expected)

 

I find that sorting via the IDW is far better. Curtis has some code on his blog which can help.

 

Anyway here is some code to help you sort in the Assembly Environment.

 

 

' 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.PartsOnlyViewEnabled = True

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


Call oBOMView.Sort("BOM Structure",True ,"TYPE",True ,"Stock Number",True)

'Re-Number the BOM
Call oBOMView.Renumber(1, 1)
MessageBox.Show("Done", "Sort BOM")
Reg
2025.2