2 Replies Latest reply on Feb 27, 2017 1:57 AM by Seckin Uslu

    save as jpg macro

    Seckin Uslu

      Hi all

      I am noby about Macro. I have recorded a macro which is a one command and getting isometric view and save as jpg

      However ı have an error. I am looking for your help even it is a simple solution.

       

      Dim swApp As Object

       

       

      Dim Part As Object

      Dim boolstatus As Boolean

      Dim longstatus As Long, longwarnings As Long

       

       

      Sub main()

       

       

      Set swApp = _

      Application.SldWorks

       

       

      Set Part = swApp.ActiveDoc

      Part.ShowNamedView2 "*Isometric", 7

      swPart = swApp.OpenPart()

      Set Part = Nothing

      swApp.CloseDoc "Part11"

      longstatus = Part.SaveAs3("C:\Users\suslu\Desktop\Part1.JPG", 0, 0)

      End Sub

        • Re: save as jpg macro
          Deepak Gupta

          Seckin, try these codes.

           

          Option Explicit
          Dim swApp           As SldWorks.SldWorks
          Dim swModel         As SldWorks.ModelDoc2
          Dim saveFileName    As String
          Sub main()
              
          Set swApp = Application.SldWorks
          Set swModel = swApp.ActiveDoc
          
          swModel.ShowNamedView2 "*Isometric", -1
          swModel.ViewZoomtofit2
          
          saveFileName = Left(swApp.ActiveDoc.GetPathName, Len(swApp.ActiveDoc.GetPathName) - 6) + "JPG"
          swModel.Extension.SaveAs saveFileName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, nErrors, nWarnings
          
          End Sub