Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Configuration specific custom properties issue 1

Status
Not open for further replies.

mihalj

Mechanical
Apr 15, 2009
40
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!
 
Replies continue below

Recommended for you

Hello,

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
 
Right on! Thanks, but if you can just explain me why my posted portion of code was not correct. Why swConfig does not pull correct configuration of the part if it calls ActiveConfiguration? This is similar as swModelDoc = swApp.ActiveDoc which means swModelDoc object looks for current open document in SW application. Thanks again!
 
In your code you are using the configuration manager of the model (swComp.ConfigurationManager. I can suspect that swComp is pointer to IModelDoc2 object). So for all instances of this model document in the assembly the active configuration is equal and can differs from Referenced configuration.

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
 
swComp is exactly what you said - part with many configurations. But what is not clear to me is whenever same part was called configuraton manager was looking that part with its current configuration (it was making that configuration ActiveConfiguration). I guess even though it is not completely clear to me why, simply I need to remember your way of approaching to referenced configurations.
Thanks again!
 
The ModelDoc2 object itself doesn't refer to component and doesn't get any information of it (such as referenced configuration).

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
 
I think I understand it now.
Thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor