Save as copy with a subset of the configuration with macro

Programming and macros
User avatar
Hansjoerg
Posts: 111
Joined: Thu Apr 01, 2021 4:17 pm
Answers: 3
x 72
x 58

Save as copy with a subset of the configuration with macro

Unread post 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?
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.
User avatar
AlexB
Posts: 452
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 24
x 243
x 401

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

Unread post 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
Post Reply