Exporting Values with Python4Capella

Using a new Capella 6.0.0 and the latest releases of the PVMT add-on and Python for capella, and also using Python 3.9 interpreter the script finally worked, I do not why I was having troubles before but anyway thanks for the help!

1 Like

Hi, I am using this topic again because I have an issue with one of the scripts that you provided me before in this conversation.
I have used this script to extract attributes and values of requirements:
for req in se.get_all_contents_by_type(Requirement):

    # Extracts Requirement Type
    if req.get_java_object().getRequirementType() != None:
        print("Type: "+req.get_java_object().getRequirementType().getReqIFLongName())
    
    # Extracts Requirements Attributes and Values
    if req.get_java_object().getOwnedAttributes() != None:
        for att in req.get_java_object().getOwnedAttributes():
            print("- Attribute: "+att.getDefinition().getReqIFLongName()+", value: "+str(att.getValue()))

With Capella 5.2 it was working but now on Capella 6.0 and a new model this error is being printed:

					org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
					  File "workspace://test_1/test_6.py", line 99, in <module>
					    if isinstance(value, integer_types):
					  File "C:\Users\Utente\Desktop\capella test 2\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py", line 1321, in __call__
					    return_value = get_return_value(
					  File "C:\Users\Utente\Desktop\capella test 2\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\protocol.py", line 330, in get_return_value
					    raise Py4JError(
					py4j.protocol.Py4JError: An error occurred while calling o9779.getValue. Trace:
					py4j.Py4JException: Method getValue([]) does not exist
						at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
						at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
						at py4j.Gateway.invoke(Gateway.java:274)
						at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
						at py4j.commands.CallCommand.execute(CallCommand.java:79)
						at py4j.ClientServerConnection.sendCommand(ClientServerConnection.java:244)
						at py4j.CallbackClient.sendCommand(CallbackClient.java:384)
						at py4j.CallbackClient.sendCommand(CallbackClient.java:356)
						at py4j.reflection.PythonProxyHandler.invoke(PythonProxyHandler.java:106)
						at jdk.proxy15/jdk.proxy15.$Proxy28.executeScript(Unknown Source)
						at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.internalExecute(Py4jScriptEngine.java:240)
						at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.execute(Py4jScriptEngine.java:227)
						at org.eclipse.ease.AbstractScriptEngine.inject(AbstractScriptEngine.java:189)
						at org.eclipse.ease.AbstractScriptEngine.run(AbstractScriptEngine.java:242)
						at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

It seems that with some of the “req.get_java_object().getOwnedAttributes()” is not possible to use getValue, I tried also get_Value and getvalue and a few other functions but it didn’t work either

I think this is related to this issue:

Yes that was the problem, thank you!

1 Like