4 Replies Latest reply on Mar 16, 2018 12:17 PM by Deepak Gupta

    Batch Drawing update

    Erik Rotolo

      I am trying to write a batch process to update drawings file to Restrict Top Level BOMs To One Configuration, but i'm getting a runtime error 91 at

       

      boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swOneConfigOnlyTopLevelBom, 0, True)

       

      what am I doing wrong???  Please see code below.

       

       

       

      Option Explicit

       

      Dim swApp        As SldWorks.SldWorks

      Dim swModel      As SldWorks.ModelDoc

      Dim sFileName    As String

      Dim nFileName    As String

      Dim Path         As String

      Dim nPath        As String

      Dim nErrors      As Long

      Dim nWarnings    As Long

      Dim Part         As Object

      Dim boolstatus   As Boolean

      Dim longstatus   As Long, longwarnings As Long

       

      Sub main()

       

       

          Set swApp = Application.SldWorks

            

          Path = "D:\SolidWorks\Library" 'Change file path here

         

          Path = Path + "\"

         

          sFileName = Dir(Path & "*.slddrw")

         

         

          Do Until sFileName = ""

       

       

          Set swModel = swApp.OpenDoc6(Path + sFileName, swDocDRAWING, swOpenDocOptions_Silent, "", nErrors, nWarnings)

       

       

          Set swModel = swApp.ActiveDoc

         

         

          'Restrict Top Level BOMs To One Configuration

              

              boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swOneConfigOnlyTopLevelBom, 0, True)

             

               swModel.EditRebuild

                          

             swModel.Save

            

         swApp.CloseDoc swModel.GetTitle

        

         Set swModel = Nothing

        

         sFileName = Dir

        

      Loop

       

       

      End Sub