I am trying to write a script to export the list of Physical Links and associated information in an Excel file.
I have associated an “Electrical Class” to physical links by using PVMT addon and an enumeration property :
for a_physical_link in all_physical_links:
# get Class of the Physical Link (PVMT addon)
physical_link_class = 'UNSET'
for pv_name in PVMT.get_p_v_names(a_physical_link):
if pv_name == 'PhysicalLinkClass':
physical_link_class = PVMT.get_p_v_value(a_physical_link, pv_name)
print(" physical_link_class =", physical_link_class)
<<<<<<<<<<<< Source code extract end <<<<<<<<<<<<
The print() command does not provide the Litteral value such as POWER or USB2 but the console output as below :
This method has been fixed in version 1.0.0 of Python4Capella and now return a String corresponding to the Litteral value. You can check differences between your pvmt.py file and the last version here and remplace it or merge needed changes in your workspace.
You can also update to one of your latest release is you didn’t make any changes in the Python4Capella project in your workspace.
Hello Yvan,
Thank you very much for your support.
My Python for Capella version is “Release 2021-12-13” and I am afraid I do not see any difference between the pvmt.py file you propose through the link and the one I got from the release.
To confirm, I replaced my pvmt.py file with the one from the link and I have identical console output result.
Kind regards.
OK you are using Team for Capella, I thought the “EnumerationPropertyLiteral[TRANSIENT]” was a reference to an Object but it’s a String returned by calling toString() on that object. Can you try with this code:
def get_p_v_value(elem, PVName):
"""
status: OK
"""
for group in elem.get_java_object().getOwnedPropertyValueGroups():
for pv in group.getOwnedPropertyValues():
if PVName == pv.getName():
if pv.eClass().getName() == "BooleanPropertyValue":
return str(pv.isValue())
elif pv.eClass().getName() == "EnumerationPropertyValue":
if pv.getValue() is not None:
return pv.getValue().getName()
else:
return None
else:
return str(pv.getValue())
return None