Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oDrawingView As DrawingView
Set oDrawingView = oSheet.DrawingViews(1)
Dim oAssydoc As AssemblyDocument
Set oAssydoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oBOM As BOM
Set oBOM = oAssydoc.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
Dim oBOMView As BOMView
Set oBOMView = oBOM.BOMViews.Item("Structured")
Call oBOMView.Sort("BOM Structure", True, "Part Number", True, , True)
'
The above line not working properly, It sorts only the first a criteria i.e. BOM Structure. And if change the first one to Part Number the only the part number will work. At any point of time only the first sorting criteria is working.
Solved! Go to Solution.
Solved by xiaodong_liang. Go to Solution.
Hi,
firstly, there is a typo in the last line. The TertiaryColumnTitle is not set, while the TertiaryColumnAscending is set to true.
But this is not a problem. Even though I use Call oBOMView.Sort("BOM Structure", True, "Part Number", True), the issue can reproduce. The second column is not sorted.
I logged this issue with the engineer team.
STILL an issue in 2016, 4 years later.
ie; Trying to sort BOM with a custom iProp column (Work Order #) sorted first, and mass sorted second.
Will sort mass just fine, but I can't set the option for what order to sort the custom iProp; it always sorts ascending even though it is completely numerical..
There is a way to sort BOM by more then one column:
Instead of trying to do it this way:
oBOMView.Sort("BOM Structure", True, "Part Number", True)
Do it this way: first sort by the second column and then by the first.
oBOMView.Sort("Part Number", True)
oBOMView.Sort("BOM Structure", True)
There is a way to sort BOM by more then one column:
Instead of trying to do it this way:
oBOMView.Sort("BOM Structure", True, "Part Number", True)
Do it this way: first sort by the second column and then by the first.
oBOMView.Sort("Part Number", True)
oBOMView.Sort("BOM Structure", True)
Hi
Actually, this never works properly. You might get lucky, but don't bank on it. I guess it depends on your environment, but I had some strict sorting rules, and they never really worked consistently.
I have found that sorting in the drawing environment to be the most stable.
Create a dummy drawing and place all the Parts Lists in there. Using iLogic, you can sort multiple parts lists with a few mouse clicks.
These can then write back to the assemblies, and give a consistent BOM sort. (I wrote some code the other day to sort the BOM by item number, you cant go wrong with that one, LOL)