AnsweredAssumed Answered

How to sort weldment cut list table with respect to item number

Question asked by Manikandan Babu on Mar 11, 2015
Latest reply on Mar 12, 2015 by Manikandan Babu

Dear all,


           I have tried to automate the cutlist generation.


Option Explicit

Const WeldmentTableTemplate As String = "C:\Program Files\SolidWorks Corp\SolidWorks\lang\english\cut list.sldwldtbt"

Dim swApp As SldWorks.SldWorks

Dim swmodel As SldWorks.ModelDoc2

Dim WMTable As SldWorks.WeldmentCutListAnnotation

Sub main()

Set swApp = Application.SldWorks

Set swmodel = swApp.ActiveDoc

Dim swdraw As SldWorks.DrawingDoc

Dim swview As SldWorks.View

swApp.DocumentVisible False, 0

Set swdraw = swApp.NewDocument("C:\MECH_PDM\3D CAD\6. SW Data\Templates\Detail A2.drwdot", 0, 0, 0)

Set swview = swdraw.CreateDrawViewFromModelView3(swmodel.GetPathName, "*Front", 0, 0, 0)

Set WMTable = swview.InsertWeldmentTable(False, 0.1996662889191, 0.1013905859662, swBOMConfigurationAnchor_TopLeft, "Default<As Welded>", WeldmentTableTemplate)

Dim swanntable As SldWorks.TableAnnotation

Set swanntable = WMTable

Dim status As Boolean


WMTable.Sort 0, True


swanntable.SaveAsText "C:\Users\inmab2\Desktop\svc itemlist\BA.txt", vbTab

Call Saveexcel

'swApp.CloseAllDocuments (True)

End Sub


how to sort the table with respect to ITEM NO. WMTable.Sort 0, True(not working)

its working fine with respect to QTY. WMTable.Sort 1, True

please refer the screen shot and help me to solve this.