5 Replies Latest reply on May 30, 2018 12:44 PM by Eric Jacobson

    Macro - Export all parts in assem to IGS

    Kody Spaberg

      Did a bit of searching I wasn't really able to find what I'm looking for.


      I'm often working with 3-6 different assemblies a day for different products. It's common that I will have to make minor changes that affect all of the parts and have to individually go to each part and save as an IGS for my cnc programmer. I'm looking for a macro that does just that: from an assembly, saves all the individual parts to IGS. It would be a bonus if I could do this from the drawing file, where it saves every part with an active drawing view to an IGS file while saving the drawing to a PDF.. but I figure that's asking a bit much.

        • Re: Macro - Export all parts in assem to IGS
          Manikandan Babu

          Hi Kody,


          Try this code-from an assembly, saves all the individual parts to IGS


          Dim swApp As SldWorks.SldWorks

          Dim SWMODEL As SldWorks.ModelDoc2

          Dim Swassm As SldWorks.AssemblyDoc

          Dim Swcomp As SldWorks.Component2

          Dim Swcompmodel As SldWorks.ModelDoc2

          Dim swExportPDFData     As SldWorks.ExportPdfData

          Dim Vcomps As Variant

          Dim i As Integer

          Dim lErrors As Long

          Dim lWarnings As Long

          Dim fileloc As String

          Dim Filename As String


          Sub main()

          Set swApp = Application.SldWorks

          Set SWMODEL = swApp.ActiveDoc

          Set Swassm = SWMODEL

          fileloc = Left(SWMODEL.GetPathName, Len(SWMODEL.GetPathName) - Len(SWMODEL.GetTitle))

          Vcomps = Swassm.GetComponents(False)

          For i = 0 To UBound(Vcomps)

          Set Swcomp = Vcomps(i)

          Set Swcompmodel = Swcomp.GetModelDoc2

          Filename = Left(Swcompmodel.GetTitle, Len(Swcompmodel.GetTitle) - 6)

          Swcompmodel.Extension.SaveAs fileloc + Filename + "igs", 0, 0, swExportPDFData, lErrors, lWarnings


          End Sub



          • Re: Macro - Export all parts in assem to IGS
            Eric Jacobson

            This is saving off igs named as each detail, but it contains the entire assembly, not only the individual details.


            Am i doing something wrong? I have the assembly open and I'm running this from there.


            All the file sizes are the same size as well.


            Sorry to resurrect an older thread.