Search code examples
vbaselectioncatia

Calling user reference properties in CATIA using VBA


I'm looking to call user referenced properties in CATIA. Currently I am able to do this through a direct path using:

xyz = CATIA.Activedocument.product.UserRefProperties.Item("DESIGNER").Value
MsgBox (xyz),0

I'm looking to generalize so that what ever the user is selecting in the window, that information will be displayed. I'm able to do something similar to what my goal is using code like this:

abc = CATIA.ActiveDocument.Selection.Item(1).Value.Name
MsgBox (abc),0

This gets to my issue. The above code will call system defined properties based on selection, however, this will not work on the user defined properties.

How can I modify this code to take the information stored in a user defined property and display it?


Solution

  • You might have a problem due to the fact that starting at level 2 substructure, your selection does not hold a Reference, but an instance, try this code (I display the 1st User Added Property of the selected product)

    MsgBox CATIA.ActiveDocument.Selection.Item(1).LeafProduct.ReferenceProduct.UserRefProperties.Item(1).ValueAsString