2 Replies Latest reply on Jun 8, 2015 11:06 AM by Normand Roy

    Generate STL file with configuration name for my macro

    Normand Roy

      Hi, im new to this forum. I wish i am at the right place to post my request. I am getting started with SW Macro!

      All i want is to export over 1000 different configuration of one solidworks part into stl file. I know there is different way to proced. There is what i tried.

       

      I made each configuration with design table with $PRP:"SW-Configuration Name" linked to my wrap text.

      Then i record a quick macro to save my current part into stl file by one click.

      I figured it would be easier to begin with a simple command like that. I know i could use bach exportation but i need to master how to simply export my file into stl with the configuration name.  Actually, it generate a stl file according to my part name.

      The problem is i have to manually rename each stl file.

       

       

       

      part1.jpg

       

       

      There is my VB file generated by SW macro

       

      Dim swApp As Object

      Dim Part As Object

      Dim boolstatus As Boolean

      Dim longstatus As Long, longwarnings As Long

       

      Sub main()

       

      Set swApp = _

      Application.SldWorks

       

      Set Part = swApp.ActiveDoc

      longstatus = Part.SaveAs3("C:\Users\Normand\Desktop\bague #9339_1, 2_epaisseur.STL", 0, 0)

      End Sub

       

      Actually i just want to know how to swap original save name with the configuration part in use

       

      Forgive me, english is my second language.

       

      Thank you.

       

      Normand

        • Re: Generate STL file with configuration name for my macro
          Simon Turner

          Part.SaveAs3("C:\Users\Normand\Desktop\" & Part.ConfigurationManager.ActiveConfiguration.Name & ".STL", 0, 0)

           

          Be careful not to use any characters such as * ? \ / in the configuration name.

            • Re: Generate STL file with configuration name for my macro
              Normand Roy

              Wow! That was fast and easy! Very helpful.

               

              Here is what i have done to loop my batch.

              Now i have a SW instance running for hours exporting all i want!

               

               

              Dim swApp As Object

              Dim Part As Object

              Dim boolstatus As Boolean

              Dim longstatus As Long, longwarnings As Long

              Dim i As Integer

               

              Sub main()

               

              Set swApp = _

              Application.SldWorks

              Set Part = swApp.ActiveDoc

               

              i = 9339

              Do Until i = 10000

              boolstatus = Part.ShowConfiguration2(i)

              longstatus = Part.SaveAs3("S:\Production\Production OAM\_Ressources\Bagues identification\" & "Bague # " & Part.ConfigurationManager.ActiveConfiguration.Name & ".STL", 0, 0)

              i = i + 1

              Loop

               

               

              End Sub