[Python4Capella] How to fetch description of a property in PVMT?

I created a few test property-values and applied them to some System Functions of the IFE model. I want to be able to export all PVMT data using P4C. I am able to export the domain, extension, name, type and value details with ease but the description returned is always “null” or “None”.

Screenshot from the .capella file:

P4C code snippet:

for sysFun in allSysFun:
    for item in sysFun.get_owned_property_value_groups():
        print(item.get_name()) #Domain.Extension
        for item2 in item.get_owned_property_values():
            print(item2.get_name()) #Property
            print(item2.get_description())
            print(item2.get_type().get_name()) #PropertyType
            print(item2.get_value().getName()) #PropertyValue
            print(item2.get_value().getDescription())

Could somebody help me out and guide me in the right direction?
Thanks!

I think you made a little mistake:

print(item2.get_value().getDescription())

should probably be:

print(item2.get_value().get_description())

Thanks Yvan, but I tried that already and it gives the “Method get_description([]) does not exist” error.

Is it possible that PVMT stores description text as something other than “description”? I’ve tried summary as well but that is null/none too.

Yes the value here is an enumeration value.

By looking at the model

print(item2.get_description())

Should return the description…

You can try to call the Java method directly:

print(item2.get_java_object().getDescription())

See if you get a better result.

Unfortunately that too is not working.
This is the output I get with the updated code statement:

image

Proof that the property has been applied to system functions (IFE sample model):

Already included the .capella file that shows the property definition.
If my property creation and application are correct, I am unable to understand why I can’t fetch the description. I am using Capella 5.2 if that helps…

I don’t have a Capella 5.2.0 installeb but I tried the following script on Capella 6.0.0 and 5.1.0:

# name                 : Print description in console
# script-type          : Python
# description          : Print description in console
# popup                : enableFor(org.polarsys.capella.core.data.capellacore.CapellaElement)

# include needed for the Capella modeller API
include('workspace://Python4Capella/simplified_api/capella.py')
if False:
    from simplified_api.capella import *

# Retrieve the Element from the current selection and its aird model path
selected_elem = CapellaElement(CapellaPlatform.getFirstSelectedElement())

print(selected_elem.get_description())

Adding this script to the sample script folder, you should be able to right click on your EnumerationPropertyValue and select the Print description in console menu. It will print the description on the console. Let me know if it works. I edited the description using the rich text editor from the property view.

This too does not work…

image

My VPD editor:

I am thinking I will try the same property-value setup in a Capella 5.1 installation and see if I’m able to fetch the description. Would greatly appreciate your advise/suggestions/help!

Update: Same issue with Capella 5.1.0 as well.

Maybe we are not talking about the same description:

You can try to print the string representation of the object you select in the script. It might show the name of the EAttribute we are looking for:

print(selected_elem.get_java_object().toString())

You can then use something like:

print(selected_elem.get_java_object().getNameOftheAttribute())

The name of the EAttribute name is description. Maybe you need to navigate from the applied property value in the Capella model to its definition in the vpd model…

Thanks Yvan, yes I think we are talking about different descriptions because:

  1. Description here is empty

  1. Description here exists

I am not sure why the description from 2nd screenshot does not appear in the description field in 1st screenshot

The description you are referring to is describing the definition of the attribute you are defining in the vpd file (Viewpoint definition).
Like if you were defining a “mass” attribute in a vpd file and you could read a text like “this attribute will be used on PCs to store the weight of physical components on the system”.
Why would you want to get this description?

Oh okay, I completely misunderstood the purpose of the description field in that case. I thought this description is tagged to the element (as part of the PV) the property is applied on and can be accessed through the property value while exporting for better documentation.

Thanks for the clarification!