Page 1 of 1

show the main configuration, not derived

Posted: Thu Aug 10, 2023 1:54 pm
by Dwight
All

I have a section in a macro (see below) that first creates a Default configuration if there isn't one already then sets the Default configuration to active. I would like to add some lines that will show the main configuration (do you call it "main"?) if there are any derived configurations and also collapse any exploded configuration that might be showing. I find nothing in help right off. Could someone suggest a line or lines to add to the section below that would do the job?

Thanks

Dwight


If swModel.GetConfigurationByName("Default") Is Nothing Then
Dim swConfig As SldWorks.Configuration
Set swConfig = swModel.AddConfiguration3("Default", "", "", swConfigurationOptions2_e.swConfigOption_UseDescriptionInBOM)
MsgBox "A Default configuration was created. Please delete other configurations if they are not needed."
End If
swModel.ShowConfiguration2 ("Default")

Re: show the main configuration, not derived

Posted: Thu Aug 10, 2023 2:31 pm
by AlexB
Off the top of my head, you could use IConfiguration.IsDerived to determine if the configuration is derived. If so, you can call IConfiguration.GetParent to get the owner configuration.

I can't find an alternative way to collapse an exploded view than using RunCommand with the following argument. I'm not sure how to check if it's currently exploded or if running this on a non-exploded configuration could cause problems but it's worth testing.

Code: Select all

swApp.RunCommand swCommands_e.swCommands_View_Collapse_Assembly, Empty ' Configuration must be selected prior to running command

Re: show the main configuration, not derived

Posted: Thu Aug 10, 2023 3:12 pm
by Dwight
I added your line to collapse the exploded view and it works great. Thanks very much.

I find that the line I already had . . .

swModel.ShowConfiguration2 ("Default")

. . . does take it from a derived configuration to the "main" configuration. So I'm all set. Thanks.