show the main configuration, not derived

Programming and macros
User avatar
Dwight
Posts: 231
Joined: Thu Mar 18, 2021 7:02 am
Answers: 2
x 2
x 191

show the main configuration, not derived

Unread post 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")
by AlexB » Thu Aug 10, 2023 2:31 pm
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
Go to full post
User avatar
AlexB
Posts: 434
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 21
x 240
x 383

Re: show the main configuration, not derived

Unread post 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
User avatar
Dwight
Posts: 231
Joined: Thu Mar 18, 2021 7:02 am
Answers: 2
x 2
x 191

Re: show the main configuration, not derived

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