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.
Get doc active configuration no matter what is loaded
Get doc active configuration no matter what is loaded
- Attachments
-
- getActiveConfOfAssy3.zip
- two assembly files (assy2, assy3) and one macro (getActiveConfOfAssy3)
- (108.81 KiB) Downloaded 36 times
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 postRe: Get doc active configuration no matter what is loaded
To read the file on disk you can use the Document Manager API to get a swDMdocument, get its ConfigurationManager, and use GetActiveConfigurationName.