Configuration specific custom properties issue
Configuration specific custom properties issue
(OP)
Hi,
here is the code I have within macro which takes part (swComp) within assembly (assembly traversal) going into specific part configuration custom properties and later writing them into excel sheet. The issue I have is related to two very same parts that I have within assembly with different configurations and both of them have different values (specific to each configuration). Issue - for both of them writes same specific custom property values and I am saying same because those values are exact for one of those parts. Did anyone had similar experience with this issue or can you tell me is this code correct.
Just to mention this code is within Do While loop and it basically going thru each part within assembly
swConfigMgr = swComp.ConfigurationManager
swConfig = swConfigMgr.ActiveConfiguration
swPartCustPropMgr = swConfig.CustomPropertyManager
If Not swPartCustPropMgr Is Nothing Then
vPartPropNames = swPartCustPropMgr.GetNames
Thanks!
here is the code I have within macro which takes part (swComp) within assembly (assembly traversal) going into specific part configuration custom properties and later writing them into excel sheet. The issue I have is related to two very same parts that I have within assembly with different configurations and both of them have different values (specific to each configuration). Issue - for both of them writes same specific custom property values and I am saying same because those values are exact for one of those parts. Did anyone had similar experience with this issue or can you tell me is this code correct.
Just to mention this code is within Do While loop and it basically going thru each part within assembly
swConfigMgr = swComp.ConfigurationManager
swConfig = swConfigMgr.ActiveConfiguration
swPartCustPropMgr = swConfig.CustomPropertyManager
If Not swPartCustPropMgr Is Nothing Then
vPartPropNames = swPartCustPropMgr.GetNames
Thanks!






RE: Configuration specific custom properties issue
Would you like to get the Configuration specific custom property from the component's referenced configuration?
If so try this code snippet:
- - - - - - - - - - - -
Dim swComp As SldWorks.Component2
Dim swCompModel As SldWorks.ModelDoc2
Dim confName As String
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim vPartPropNames As Variant
Set swCompModel = swComp.GetModelDoc2
confName = swComp.ReferencedConfiguration
Set swCustPropMgr = swCompModel.Extension.CustomPropertyManager(confName)
If Not swCustPropMgr Is Nothing Then
vPartPropNames = swCustPropMgr.GetNames
End If
End Sub
- - - - - - - - - - - -
the swComp is the pointer to current component
Artem Taturevich
CSWP
RE: Configuration specific custom properties issue
RE: Configuration specific custom properties issue
You can check it next way:
1) Create new simple part with several configuration.
2) Insert in the assembly several instances of this part.
3) Change the referenced configuration for each component.
4) Now opening this part note that active configuration remains as was. You can also change it in the part and the referenced configurations of the component won't change.
The similar situation was in your code. You always get the property manager of the active configuration which is the same for each underlying document of the component regardless its referenced configuration. That's why you always get the same values of custom properties.
Thanks,
Artem Taturevich
CSWP
RE: Configuration specific custom properties issue
Thanks again!
RE: Configuration specific custom properties issue
Whenever you call ActiveConfiguration method you are working with ModelDoc2 document but not Component2 so the first one "know nothing" about second one.
The model document is able to has only one active configuration at a time.
Thanks,
Artem Taturevich
CSWP
RE: Configuration specific custom properties issue
Thanks a lot!