3 Replies Latest reply on Nov 21, 2014 1:41 PM by Brian Titus

    how to save a part as .step in a specified folder

    N. V

      I've been trying to create a macro that saves a part as a .step file, while saving all created step files into a specified folder (for example "C:\step\").

      I know there is a way to run the macro and the specify the folder yourself, but I want to have it automatically saved into the same folder every time.

       

      Can anyone help me with this?

      Right now I have this:

      ------------------------------------

      Option Explicit

       

      Dim swApp As Object

      Dim Part As Object

      Dim FilePath As String

      Dim PathSize As Long

      Dim PathNoExtention As String

      Dim NewFilePath As String

      Dim FileLocation As String

      Dim Rev As String

       

      Sub main()

      Set swApp = Application.SldWorks

      Set Part = swApp.ActiveDoc

       

      FilePath = Part.GetPathName

      PathSize = Strings.Len(FilePath)

      Rev = Part.CustomInfo("Revision") ' Change Custom Property Here

      FileLocation = "C:\step\"

       

      PathNoExtention = Strings.Left(FilePath, PathSize - 7)

       

      NewFilePath = FileLocation & PathNoExtention & " REV " & Rev

       

      Part.SaveAs2 NewFilePath & ".STEP", 0, True, False

       

      End Sub

      ---------------------------------

       

      Thanks