Hi Everyone,
I was wondering if any of you would be kind enough to explain to me the difference between iModelDoc2.GetActiveConfiguration and iComponent2.referenced configuration. I discovered for a macro I'm writing, that I needed to use the latter for it to work correctly, and GetActiveConfiguration was giving me the incorrect config/custom properties that i was trying to pull. What is the practical difference between the two, and how can you tell what the "Active Configuration" will be predictably? Or is it better practice to use the component?
Thanks in advance!
-Drew
SolidworksApi macros
The active configuration is whichever config is currently being displayed if the part is open or whichever was displayed when it was saved if it is not open. Unless you specifically tell the macro which configuration to display, you have no way of predicting what configuration this will be.
The iComponent2::ReferencedConfiguration is whichever configuration is specified to be used in the assembly for that particular component.
I'm not sure what your macro is trying to accomplish, but my guess is that "ReferencedConfiguration" will give you better results.
Thanks Patrick.
I'm basically traversing an assembly, and summing Sale Prices. If it's a sub assembly, I use a Price 1custom property, and if it's a top level part in the parent assembly, I use a Price 2 property.
As you said, Referenced Configuration is giving me the correct results. I'm still learngeting the API, so my first instinct was to use GetActiveConfiguration, which was behaving seemingly unpredictably.
Thank you for your reply.
Also, side question, any idea on how to snag custom properties from "parts only" in a sub assembly? Right now, i'm dissolving all the sub-subassemblies to grab the custom props, but I am certain there's a better way.
-Drew
Use IComponent2::GetChildren to get an array of components in the sub-assembly. Loop through the array of child components and get the properties.