Get doc active configuration no matter what is loaded

Programming and macros
Kjara
Posts: 21
Joined: Mon Jul 19, 2021 2:49 am
Answers: 0
x 1

Get doc active configuration no matter what is loaded

Unread post by Kjara »

I want to retrieve the active configuration of a model document given by its target file path.
And I want to always retrieve the value that is saved in the file, no matter what files are currently open/loaded.

How do I do that WITHOUT closing/reopening files before retrieving?

I tried using
- ISldWorks.GetActiveConfigurationName(filePath),
- first loading the IModelDoc (using IDocumentSpecification with target file path and then ISldWorks.OpenDoc7), then calling IModelDoc.ConfigurationManager.ActiveConfiguration.Name,

but both have the same problem:
If, prior to these calls, an assembly was loaded that contained the target file as a component, the calls will return the active configuration of that component, not the active configuration of the target file document.

To reproduce,
- unpack the attached two files (assy2.sldasm and assy3.sldasm) and the macro (getActiveConfOfAssy3.swp) to some folder.
- edit the macro and replace the current value of filePath variable by the correct one on your computer.
- run the macro with no open document: then the found active configuration will be Sechseck10_confName.
- run the macro with only assy2.sldasm open: then the found active configuration will be Sechseck30_confName.
Attachments
getActiveConfOfAssy3.zip
two assembly files (assy2, assy3) and one macro (getActiveConfOfAssy3)
(108.81 KiB) Downloaded 36 times
by josh » Wed Sep 14, 2022 8:48 am
To read the file on disk you can use the Document Manager API to get a swDMdocument, get its ConfigurationManager, and use GetActiveConfigurationName.
Go to full post
User avatar
josh
Posts: 263
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 11
x 19
x 456

Re: Get doc active configuration no matter what is loaded

Unread post by josh »

To read the file on disk you can use the Document Manager API to get a swDMdocument, get its ConfigurationManager, and use GetActiveConfigurationName.
Post Reply