Page 1 of 1

Save as copy with a subset of the configuration with macro

Posted: Wed Apr 27, 2022 8:55 am
by Hansjoerg
Hello all,
I have been trying to include the still relatively new Save as Copy with a subset of the configurations as a macro to get to the command.
https://help.solidworks.com/2021/Englis ... config.htm

The following command was recorded

Code: Select all

longstatus = Part.SaveAs3("F:\PressureSprings\Standard.SLDPRT", 0, 2)
Looking at the "ModelDoc2::SaveAs3" command in the help, I don't understand two things.
1. the command is obsolete, why is it still used in SWX 2021 SP 05.1?
2. there is no option to specify which configuration to save?

I then also ran the code to see if it even executed correctly. A new file is created, but it still contains all the configurations.
Not exactly what I expected.

On the following page: http://solidworks.cad.de/mm_30.htm
I found a macro that does exactly this task. But it also creates a copy of all existing configurations and then deletes the ones that are no longer needed.
But since I have to split files with a lot of configurations (~ 4500 configurations), I am looking for a way to speed up the processing a bit.

Does anyone have a solution how to solve saving the configuration with a macro?

Re: Save as copy with a subset of the configuration with macro

Posted: Wed Apr 27, 2022 10:22 am
by AlexB
Yeah, the macro recorder is pretty useless.
You'll want to use the IModelDocExtension.SaveAs3 function instead of the ModelDoc2.SaveAs3. The ModelDoc2 SaveAs functions are obsolete.
These are the help pages for this function and the AdvancedSaveAsOptions. The AdvancedSaveAsOptions appear to be what you're looking for to specify configurations to save, etc., although it looks less than straight forward to use.

https://help.solidworks.com/2022/Englis ... veAs3.html

https://help.solidworks.com/2022/Englis ... tions.html