1 Reply Latest reply on Sep 18, 2014 1:44 PM by Jesse Seger

    Is there a batch macro for file conversion from files with configurations to .sat? I've been looking around and i'm getting over whelmed.

    Jeff Holden

      Here is what I have in recording my macro, I was hoping to build off of this. However when I play the macro, I do not see a new .sat file created.

        • Re: Is there a batch macro for file conversion from files with configurations to .sat? I've been looking around and i'm getting over whelmed.
          Jesse Seger

          Give this a try.  Remember to change the folder name.

           

          Dim swApp As SldWorks.SldWorks

          Dim boolstatus As Boolean

          Dim longstatus As Long, longwarnings As Long

           

           

          Sub main()

           

           

          Set swApp = Application.SldWorks

           

           

           

           

              Dim MyObj As Object, MySource As Object

              Dim file As Variant

              Dim folder As String

            

            

              '********************* change the folder name *********************

              folder = "c:\testfolder\"

            

              file = Dir(folder)

              While (file <> "")

                  Dim swModel As ModelDoc2

                  Dim ext As String

                  Dim newFile As String

                  ext = LCase(Right(file, 6))

                

                  If ext = "sldasm" Then

                      Set swModel = swApp.OpenDoc(folder & file, swDocumentTypes_e.swDocASSEMBLY)

                      newFile = folder & Replace(LCase(file), "sldasm", "sat")

                  ElseIf ext = "sldprt" Then

                      Set swModel = swApp.OpenDoc(folder & file, swDocumentTypes_e.swDocPART)

                      newFile = folder & Replace(LCase(file), "sldprt", "sat")

                  End If

                

                  If Not swModel Is Nothing Then

                    

                      Dim configs As Variant

                      configs = swModel.GetConfigurationNames

                    

                      For Each config In configs

                          swModel.ShowConfiguration2 config

                         '**************  add configuration name to file  *******************

                          newFile = Replace(newFile, ".sat", "-" & config & ".sat")

                         

                          swModel.SaveAs newFile

           

                      Next

                      swApp.CloseAllDocuments True

                  End If

                

                  file = Dir

              Wend

           

           

          End Sub