Hi all
Please don't flame me, this is a re-post from the "customization Board"
I have been searching the forum for a while now, but have been unable to find any code to sort the BOM, there are lots of snippets to sort and modify the Parts list. (Curtis Wageuespackhas done a lot on this)
Does anyone have something to sort the Assembly BOM?
Any help will be appreciated.
Thank you.
Sort parameters:
PARTS Only
"BOM Structure"
then by
Custom Parameter "TYPE"
Then By
Part Number
Then "Renumber" starting at 1
Hi there
I have been playing around a bit and have managed to get the BOM to sort on one item list only. Can someone perhaps debug my code and help with the multiple sort?
I have commented out the WORKING string, the one that I need is just above it.
Thanks guys.
' Set a reference to the assembly document. ' This assumes an assembly document is active. Dim oDoc As AssemblyDocument oDoc = ThisApplication.ActiveDocument Dim SortBOM As Boolean If MsgBox("Sort The BOM?", vbYesNo) = vbYes Then SortBOM = True Else SortBOM = False End If ' Set a reference to the BOM Dim oBOM As BOM oBOM = oDoc.ComponentDefinition.BOM ' Set whether first level only or all levels. If SortBOM Then oBOM.PartsOnlyViewEnabled = True Else Return 'oBOM.PartsOnlyViewEnabled = False End If ' Make sure that the structured view is enabled. oBOM.PartsOnlyViewEnabled = True 'Set a reference to the "Structured" BOMView Dim oBOMView As BOMView oBOMView = oBOM.BOMViews.Item("Parts Only") 'Sort the BOM Call oBOMView.Sort("BOM Structure",True,"TYPE",True,"Part Number",True) ''The following line works correctly 'Call oBOMView.Sort("Part Number",True) 'Re-Number the BOM Call oBOMView.Renumber(1, 1)
Hello
i had the exact same problem. It would not sort on 3 criteria.
Talked to one of our trainers, and he told me this is an inventor error.
What i am doing is sortin and exporting the part list on the drawing (sorting works on the drawing sheet). After this i override the assy BOM from the drawing and reorder it depending on ITEM.
I dont have the filan code yet, but i know it works. Tested part of code.
Offcourse if you do not have a drawing yet, then this is not good. In my situation I always have a drawing.
If you want i can send you my code wheen i am done...
Hope this helps.
Hey
I managed to make it work.
Look at the following thread
If you need any more help please tell...and dont forget to mark as solution if it's ok.
Thanks