Active configuration on opening

Hello;

I'm still working in Solidworks 2022, but I think my question isn't limited by the software version.
In our assemblies, we work primarily on the " Default " configuration.
As our work progresses, other configurations are created on these assemblies (most of the time the "Transport " configuration ).

Could you tell me if it is possible to open the " Default " configuration as a priority even if other configurations have been created in the meantime.

Currently, Solidworks opens our assemblies on the last active configuration, but it is not necessarily the most " readable " configuration...

PS: Yes, it would be possible to create a macro for opening (or closing) assemblies but I don't really like the " macro integrated into design trees" side that this would impose.

PS2: Using the Mycad tools, I can also use " integration " to force the active configuration of the assemblies but, again, this is not really a sustainable solution.

Regards.

Good evening,

To my knowledge not possible, SW reopens on the last active configuration at the time of closing/saving.
It's a bit the same behavior on PDM which displays the data of the active conf (typically an absurdity in the context of drawings that don't have a config)

Can a macro do it? Given that there is a possible choice when opening a SolidWokrs document?

I asked an old AI smart friend

"To ensure that this opening on the " Default " configuration is systematic without having to run the macro manually each time, the most efficient method is to intercept the SolidWorks file open event via an add-on macro or startup script. "

Good evening,

You can optionally make a recording macro that selects ' default ' and saves.
Then you make a personal icon that calls this macro and you place the icon next to the classic save icon.

At the time I had made one to zoom in all before recording (which allows you to have a SW icon that looks like something).

2 Likes

Hello;

Between making a macro and thinking about activating the addoc configuration before recording it's still kif/kif.
I'll look at the registry, you never know...

Hello,

Yes it's doable but to intercept SW Events, you have to modify the command line that launches SW to add the fact of launching this macro when opening it.
Another disadvantage is that you have to cement the code so as not to end up in unmanaged cases.
The @froussel proposal is the "simplest  " and it's the one I use on my side (I was even close to removing the classic recording icon, I just moved it after all the macros we developed).
@Maclane , in the register I don't think it manages. In my opinion it's in the main code of SW (and since there is nothing in the options in my opinion it's screwed)

2 Likes

The problem is the fact of thinking about :slight_smile: it. Depending on the users, it can be the lottery.
A macro instead of the save icon (see to be more vicious get the SW icon and apply it to the macro button) allows you to free yourself from the goodwill of users to respect the " rules " of CAD management.

@Cyril_f

An icon, a dialog box (Like when you open via SW) fetch the model, the model opens and automatically sets to the default config.

Or launch a macro at night that performs this task :thinking:

That's the basic way SW works when you open a file via the explorer
image
The problem is when you double-click on the file or open it directly from the list of the last opened.
For macros that run at night it's doable but better to go through the task scheduler which will be more robust on the file closure side.
The most effective in my opinion is still to have something that allows you to do it systematically without going through a massive correction phase by days/weeks/months/years.

1 Like

Hello;

By going through the register, you should be able to modify the key:

HKEY_CLASSES_ROOT\SldAssem.Document\shell\open\command\

and force it to execute a PowerShell script (*.ps1) of the following type:

Start-Process "C:\...\SLDWORKS.exe" -ArgumentList "/config ""NomDeLaConfiguration"" ""C:\Chemin\...\Fichier.sldasm"""

I'm going to snoop around on this side ... but I'm open to all proposals.

I'm also looking to see if we could add a little script on the right-click of the Windows explorer to add the " Open Configuration..." function
Sometimes it's easier than we (sometimes)... :sweat_smile:

2 Likes

Hello,

The simplest and cleanest is a small add-in in vbnet or C# preferably with interception of the FileOpenPreNotifyEventHandler event:

Then we can take only the assemblies for example, check the config, not open the file if the config is not the one you want and reopen it with the right one.

The equivalent is possible in vba, but here you have to go through a batch srcipt that will open solidworks or modify the solidworks launch shortcut to launch the macro:

"C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\SLDWORKS.exe" /m "C:\Macros\EcouteurEvents.swp"

Learning a little C# is definitely worth it when you see how much you can do in an addin :wink:

1 Like