I have just started using Python4Capella, and when arrived to pvmt access, I had a couple of problems. I read the topics:
- Setting Property Values with Python4Capella
- Applying a PropertyValue that is defined in PVMT Add-on to a new Component
and the github issue https://github.com/labs4capella/python4capella/issues/168
Following the last P4C release, I started to use the new methods for PVMT class and I had a problem with
@staticmethod
def get_or_apply_property_value_group(elem: CapellaElement, propertyValuePackageName: str, propertyValueGroupName: str) → PropertyValue:
Running it as it is I receive this error message:
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “workspace://UserScripts/user_scripts/main2.py”, line 54, in
File “workspace://Python4Capella/simplified_api/pvmt.py”, line 162, in get_or_apply_property_value_group
Extension to standard InteractiveConsole so we can handle and capture
File “workspace://Python4Capella/simplified_api/capella.py”, line 603, in set_value
File “C:\Users\a.mastropietro\Softwares\Capella\capella-6.1.0.202303291413-win32-win32-x86_64\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1313, in call
args_command, temp_args = self._build_args(*args)
File “C:\Users\a.mastropietro\Softwares\Capella\capella-6.1.0.202303291413-win32-win32-x86_64\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1283, in _build_args
[get_command_part(arg, self.pool) for arg in new_args])
File “C:\Users\a.mastropietro\Softwares\Capella\capella-6.1.0.202303291413-win32-win32-x86_64\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1283, in
[get_command_part(arg, self.pool) for arg in new_args])
File “C:\Users\a.mastropietro\Softwares\Capella\capella-6.1.0.202303291413-win32-win32-x86_64\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\protocol.py”, line 298, in get_command_part
command_part = REFERENCE_TYPE + parameter._get_object_id()
AttributeError: ‘EnumerationPropertyLiteral’ object has no attribute ‘_get_object_id’
but commenting out line 162 pv_to_apply.set_value(pv.get_value()) this method seems to work correctly, creating the PVMT group as defined in the add-on. Then changing the values manually, everything works.
Is this a good solution or should 162 line do something I have not understood?
Thanks for the help!