3 Replies Latest reply on Jul 27, 2016 8:05 AM by Michał Radecki

    Macro for saving flat patterns

    Michał Radecki



      I'm trying to modify a macro I found here on the forum to suit my needs; unfortunately - without a success.

      I need to save flat pattern of the open part in "DXF" subfolder. No configurations needed.


      I've found this one, but can't make it save the file directly into the folder I need. I coped with removing config from the filename (since I don't need it), but not with the proper folder saving.


      It has been prepared by Deepak Gupta in this thread: Macro- for saving dxf flat patterns with configuration names.dxf


      Another question - is there any possible way to force SW to search whole assembly file for sheet metal parts and save them all automatically?

        • Re: Macro for saving flat patterns
          Michał Radecki

          OK, managed to do this.


          Sub main()


              Dim swApp As SldWorks.SldWorks

              Dim swModel As SldWorks.ModelDoc2

              Dim FilePath As String

              Dim NewPath As String

              Dim FileName As String

              Dim bRebuild  As Boolean

              Dim bRet      As Boolean


              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc


              FilePath = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "\"))

              FilePath = FilePath & "\DXF\"

              Set swApp = CreateObject("SldWorks.Application")

              Set swModel = swApp.ActiveDoc


              bRebuild = swModel.ForceRebuild3(False)


          FileName = swModel.GetTitle


          bRet = swModel.ExportFlatPatternView(FilePath & FileName & ".DXF", 1)


          Set swApp = Application.SldWorks


          End Sub


          Still searching for possibility to do it for whole assembly automatically