1 Reply Latest reply on Mar 2, 2018 3:43 PM by Jay Donihoo

    Can I automatically generate an export (STL) for each configuration ?

    Thibaut Thibaut.Deveraux Gmail.Co

      Hi,

       

      It could be usefull when you have something like 25 configurations...

        • Re: Can I automatically generate an export (STL) for each configuration ?
          Jay Donihoo

          Try this, I also included the swp just to make it easy but wanted to include the code as well in case someone wanted to add anything or suggest a better way.

           

          Option Explicit

          Dim swApp As Object

          Dim instance As SldWorks.IModelDoc2

          Dim swConfig As SldWorks.Configuration

          Dim ConfigList          As Variant

          Dim Config              As String

          Dim u As Long

          Dim boolstatus As Boolean

          Dim longstatus As Long, longwarnings As Long

           

          Sub main()

          Set swApp = Application.SldWorks

          Set instance = swApp.ActiveDoc

           

          ConfigList = instance.GetConfigurationNames

            

              For u = 0 To UBound(ConfigList)

                  Config = ConfigList(u)

                  Set swConfig = instance.GetConfigurationByName(Config)

                  longstatus = instance.SaveAs3("your file location.stl", 0, 0) 'you can put whatever file type you want after your location.

                  'MsgBox (Config) 'For error checking configs

                  'With ConfigBox 'for use with a userform

                    'End With

              Next u

           

          End Sub