×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Configuration specific custom properties issue

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!

RE: Configuration specific custom properties issue

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

RE: Configuration specific custom properties issue

(OP)
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!

RE: Configuration specific custom properties issue

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

RE: Configuration specific custom properties issue

(OP)
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!

RE: Configuration specific custom properties issue

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

RE: Configuration specific custom properties issue

(OP)
I think I understand it now.
Thanks a lot!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources