Sub SortBOM()
Dim symMgr As McadSymbolBBMgr
Set symMgr =
Application.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr")
Dim symBOM As McadBOM
Dim strName As String
Set symBOM =
symMgr.BOMMgr.GetBOMTable(ThisDrawing.ModelSpace, strName)
' sort the BOM based on item number
Dim symBOMItems As McadBOMItems
Set symBOMItems = symBOM.Items(True)
' sorting is always done based on the priority
of the items
Dim i As Integer
Dim j As Integer
j =
1
For i = 0 To symBOMItems.count
- 1
If
symBOMItems(i).ItemNumber =
"" Then
symBOMItems(i).SortPriority
= symBOMItems.count + j
j = j + 1
Else
symBOMItems(i).SortPriority
= CInt(symBOMItems(i).ItemNumber)
End If
Next
' lets order the items based on their
priority
symBOM.applySort
Application.Update
End Sub