Individually record all the configurations of a room in 1 go

Hello

I have a file with configurations and derived configurations, is it possible to save in STL format in 1 time and create independent files with the name of the configuration? 

1 Like

Hello

For assemblies, in the STL export options you check the option "Save all components........ " :

Then you can use a macro like this:

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

Dim V As Variant
V = swApp.GetConfigurationNames(Part.GetPathName)
   
Dim i As Long
For i = 0 To UBound(V)
    boolstatus = Part.ShowConfiguration2(V(i))
    longstatus = Part.SaveAs3(Part.GetPathName & "-" & V(i) & ".STL", 0, 0)
Next

End Sub

 

Kind regards

1 Like

I'm not in an assembly but in a part file

Hello

 

So d.roger's macro works perfectly and fully meets your request.

 

Kind regards

2 Likes

Hello

Yes, the manipulation in the options is only to be done for the assemblies, if you use the macro on parts it must work as it should and no need to intervene in the options.

Kind regards

I work in an environment that never asks me to do macros . I've never used a macro, can you show me or make me a tutorial to know how to insert this macro? Where to use it? 

Hello

Here is the macro file attached and for the installation you can follow the tutorials which can be found either HERE or HERE.

Kind regards


macroexportstlmulticonfig5.swp
4 Likes

Thank you d.roger !!

Hello

Thanks for the script. I submit the icon I made to illustrate it.

Also, I'd like to modify the script to remove the . SLDPRT that starts automatically. But when I open the code, it's unreadable, because I can't find how it was encoded.

Thank you in advance,


icon.bmp

Hello

This is the standard encoding of Solidworks macros, so to edit it, see HERE.

Kind regards

Hello everyone, thank you for the macro. In my case I want to save Step files with the name of the configuration. I installed the macro well, I tested it I see that something is happening and that sw goes over all the configurations. But how do you make the recording, decide on the format and where to record?... Thank you in advance for your help.

@Benja,

For the file path, file name, and file extension, it's all in the line below:

longstatus = Part.SaveAs3(Part.GetPathName & "-" & V(i) & ". STL", 0, 0)

Kind regards

Thank you very much d.roger for your help!
However, I'm wondering: since mesh options aren't specified in your macro, what values are used? Are they the ones specified in the last export done "by hand"?

Hello
I'll answer for him but yes it keeps the setting of the post. For my part, I force the configuration so that everyone has the same way of doing the exports.

2 Likes