AnsweredAssumed Answered

Bom sort by item no

Question asked by Niels Raahauge on Dec 16, 2019
Latest reply on Dec 17, 2019 by Niels Raahauge

Hi

Can anybody help med sorting bom by item number.

I need to sort my BOM in item order. What an I missing, or dowing wrong ?

BR Niels

 

 

' Postconditions:
'Drawing with bom table
' 1. Sorts:
'      * BOM table as follows:
'      * Primary and only sort is on column zero (ITEM).
'      * sort ascending
'      * Method_Numeric
'--------------------------------------------------------------------------
Dim swApp As SldWorks.SldWorks
Dim swmodel As SldWorks.ModelDoc2
Dim swview As SldWorks.View
Dim swTable As SldWorks.ITableAnnotation
Dim swSpecTable As IBomTableAnnotation
Dim swSortData As BomTableSortData

Option Explicit

Public Sub Main()
    Set swApp = Application.SldWorks
    Set swmodel = swApp.ActiveDoc
    Set swview = swmodel.GetFirstView 'template
    Set swTable = swview.GetFirstTableAnnotation
    Set swSpecTable = swTable
    Set swSortData = swSpecTable.GetBomTableSortData
    swSortData.ColumnIndex(0) = 0  ' primary sort on column 0
    swSortData.Ascending(0) = True ' sort ascending
    swSortData.SortMethod = swBomTableSortMethod_Numeric
    swSortData.ColumnIndex(0) = swBomTableSortItemGroup_Parts

End Sub

Outcomes