7 Replies Latest reply on Nov 17, 2017 1:32 PM by John Boire

    Format Changing in Solidworks API

    John Boire

      So, after doing a bit of research and wrote this macro to cycle through the sheets in a drawing and update their format:

       

      Dim swApp As SldWorks.SldWorks

      Dim swModel As ModelDoc2

      Dim swDraw As SldWorks.DrawingDoc

      Dim swSheet As SldWorks.Sheet

       

      Dim SheetName() As String

      Dim SheetNum As Integer

       

      Dim boolstatus As Boolean

      Dim bRet As Boolean

       

      Sub main()

       

      Set swApp = Application.SldWorks

      Set swDraw = swApp.ActiveDoc

      Set swModel = swApp.ActiveDoc

       

      swDraw.ClearSelection2 True

      SheetNum = swDraw.GetSheetCount

      SheetName = swDraw.GetSheetNames

       

       

      Debug.Print (SheetNum)

       

       

      For i = 0 To SheetNum - 1

      Debug.Print (SheetName(i))

      bRet = swDraw.ActivateSheet(SheetName(i))

       

      boolstatus = swDraw.SetupSheet4(SheetName(i), 12, 12, 1, 2, False, "Y:\Engineering\01_Engineering Technical Library\08_Ligistics\CAD Tools\SolidWorks\TEMPLATES\OPER SHEET -A-.SLDDRT", 0.2794, 0.2159, "Default")

      'Comment out 'boolstatus = swDraw.SetupSheet4(SheetName(i), 12, 12, 1, 2, False, "Y:\Engineering\01_Engineering Technical Library\08_Ligistics\CAD Tools\SolidWorks\TEMPLATES\OPER SHEET -A-.SLDDRT", 0.2794, 0.2159, "Default", True) 'Comment out

       

      Debug.Print (boolstatus)

       

      'Comment out 'boolstatus = swDraw.SetupSheet5(SheetName(i), 12, 12, 1, 2, False, "y:\engineering\01_engineering technical library\08_ligistics\cad tools\solidworks\templates\oper sketch -a-.drwdrt", 0.2794, 0.2159, "Default", True) ' Comment out

       

      swModel.ViewZoomtofit2

       

      Next i

       

      End Sub

       

      The cycle works and runs through the sheets, the path is correct (I double checked for capitalization) but for some reason the sheet format doesn't update. Is there anything I am missing?