AnsweredAssumed Answered

Batch Drawing update

Question asked by Erik Rotolo on Mar 15, 2018
Latest reply on Mar 16, 2018 by Deepak Gupta

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

Outcomes