8 Replies Latest reply on Apr 27, 2018 6:27 AM by David Dewey

    Apply Sort Macro

    Peter De Vlieger

      Does anyone have a macro which they are willing to share that will apply the saved sorting method for a BOM ?


      That there is a sort system is great, that one can save the sorting system is even better but it would be nice if we could hotkey it or hook it up to a button instead of having to RMB, wait for the menu to pop up, navigate to 'SORT', waiting for the sub menu to show itself, selecting the 'Apply Saved Sort'.

      Especially if you have to re-visit a whole bunch of drawings, as a colleague has to do, because some routing has changed and there for the items in the tables are no longer in the sequence one wanted.


      Thank you in advance.

        • Re: Apply Sort Macro
          Deepak Gupta

          Don't have one but let me try making one quickly.


          OK here are the codes. Select the BOM table from the sheet (not from feature tree) and run this macro (not error handling has been added). You can set the macro to keyboard shortcut, mouse gesture, etc.


          Option Explicit
          Dim swApp As SldWorks.SldWorks
          Dim swModel As SldWorks.ModelDoc2
          Dim swTable As SldWorks.ITableAnnotation
          Dim swSpecTable As IBomTableAnnotation
          Dim swSortData As BomTableSortData
          Sub Main()
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              Set swTable = swModel.SelectionManager.GetSelectedObject6(1, -1)
              swModel.ClearSelection2 (True)
              Set swSpecTable = swTable
              Set swSortData = swSpecTable.GetBomTableSortData
              swSpecTable.ApplySavedSortScheme swSortData
          End Sub