6 Replies Latest reply on May 10, 2016 8:48 AM by Matt Gjertson

    Don't save read only files

    Mihai Curecheru

      Hi everybody,

       

      I have a macro for Rebuild and Save part/assembly/drawing, what I have to write in macro for not saving read only documents?

       

      My macro is next:

       

      Option Explicit

      Dim swApp               As SldWorks.SldWorks

      Dim swModel             As SldWorks.ModelDoc2

      Dim swModelView         As SldWorks.ModelView

      Dim lngErrors           As Long

      Dim lngWarnings         As Long

      Dim bolStatus           As Boolean

       

      Sub main()

      Set swApp = Application.SldWorks

      Set swModel = swApp.ActiveDoc

      If swModel Is Nothing Then End

      Set swModelView = swModel.GetFirstModelView

      swModelView.EnableGraphicsUpdate = False        'Disable window updating to run faster

      swModel.ForceRebuild3 True

      swModel.ShowNamedView2 "Isometric", 7           'Usualy the Isometric View ID is 7, if you're getting problems here, replace 7 with -1 and fidle with the view's name

      swModel.ViewZoomtofit2                          'Zoom to fit

      swModelView.EnableGraphicsUpdate = True

      bolStatus = swModel.Save3(swSaveAsOptions_SaveReferenced, lngErrors, lngWarnings)

                      End Sub