Starting from a variable containing a “Capella Module” element (from the Req Addon). When calling its eClass(), it gives me:
org.eclipse.emf.ecore.impl.EClassImpl@5a9bb7dd (name: CapellaModule) (instanceClassName: null) (abstract: false, interface: false)
Yet weirdly enough, calling its name (*with
print(Seaching2.eClass().name)*), it would give this:
<py4j.java_gateway.JavaMember object at 0x000002970A803C08>
Not sure how use that item?
The Object you are referencing here is the Java Object. You will need to use the name of the Java method:
You are right, I had used getname() with “n” instead or “N” for the word name (getname() instead of getName()).
I was confused because (and I find that intriguing):
Did not work.
py4j.protocol.Py4JError: An error occurred while calling o614.get_java_object. Trace:
py4j.Py4JException: Method get_java_object() does not exist
The get_java_object() method is defined by Python4Capella on the JavaObject class. This allows to access the Java Object (in the JVM memory) of any Python4Capella Object if needed. Once you have a Java Object (in the JVM memory), you can’t call this method anymore on it but only Java defined methods.
In your case here Seaching2 is a Java Object (in the JVM memory). To check this you can use the Python function type() to see the difference: