This proved rather troublesome, and never really worked for me, so I decided to do it via the detail drawing. This works MUCH better.
The following is for my environment only, but I am sure you can adapt this for your own needs.
I have a few extra fields in my parts and assemblies, one of which is a custom parameter named "TYPE"
Notes on the iProperty fields:
"STOCK NUMBER" = Area and/or size of component, E.G "100 x 50 x 5 x 6000 RHS""COST CENTER" = Broad based item type E.G. 'TUBE' or 'PLATE'
"TYPE" = More precise item type E.G. 'SHS' or 'RHS' or 'Cleat' etc
Prerequisites:
1: In order for the code to function correctly, the Parts list must contain the fields in question.Note how the column width has been set to "1" this "hides" the column from view.
2: There is a Radiobox, true false check. This is applicable for the times you have more than one parts list present on your drawing. Once again this is due to my environment, where my marking plan will have a Structured parts list for item making via balloons as well as the itemised parts list. I will sometimes have a third parts list containing fasteners only.
This section can be removed. Comment out the fist section of the sort. (From the "If True" up to and including the "else" statement, don't forget to comment out the "End if" as well )
TIPS and Caveats
1: I have found the best way to maintain the GA partslist/BOM is to have a separate drawing containing the GA and UNFILTERED Partslist. This one becomes god, and any other GA drawings containing the partlist get sorted via item number only.2: Sub Assemblies work well with this code, and you don't need to have a separate drawing for management. you will find that the drawings become more consistent and predictable.
3: I have labeled my Fasteners with a 'z'. this forces them to the bottom of my parts list.
This process also forces you to manage and maintain a healthy BOM.
Don't forget, this writes back and updates the Assembly.
The Code:
'start of iLogic code----------------------------------------------------------------------------------
'sort parts list
oBOM = InputRadioBox("Parts List QTY", "2", "1", oBOM, Title := "PartsList Value")
If oBOM=True Then
On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(2)
oPartsList1.Sort("COST CENTER",1,"TYPE", 1, "STOCK NUMBER", 1)
oPartsList1.Renumber
oPartsList1.SaveItemOverridesToBOM
Else
On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oPartsList1.Sort("COST CENTER",1,"TYPE", 1, "STOCK NUMBER", 1)
oPartsList1.Renumber
oPartsList1.SaveItemOverridesToBOM
End If
'End of iLogic code.