Py4JException: Method eClass([])/getMinValue([]) does not exist

Hello Python4Capella

I am trying to export attributes of PhysicalQuantities in a project where has Capella 6.0.0 and Python4Capella The related part of script is as below:

all_PhyQ = se.get_all_contents_by_type(PhysicalQuantity)

for elem in all_PhyQ:
print(elem.get_name()) # OK, output like ‘Voltage’
print(elem.get_unit().get_java_object().toString().split(“(name: “)[1].split(”)”)[0]) #OK, output like ‘V’
print(elem.get_kind().getName()) # NOK, error thrown as Py4JException: Method eClass([]) does not exist
print(elem.get_min_value()) # NOK, error thrown as Py4JException: getMinValue([]) does not exist

I searched through the Scripting section but I failed after trying to append eClass(), get_class(), Javalist mentioned in other topic.

I hope goodness can help me out. Thanks.

(1) From what I see, get_kind() is not defined on PhysicalQuantity class (incomplete API) so you should use elem.get_java_object().getKind() (not sure if you need a getName() after this)
(2) Same thing, you should use elem.get_java_object().getOwnedMinValue() and you’re going to get a list as a result (may be empty if no value)

Thank you, Stephane and it works.

By the way, is there any way to find and check inherent APIs that are held by Java Object, which is returned by get_java_object()?

yes, I use 2 methods. First, I click on the desired model element in the project explorer and then:

  • either I open the property view and go to the “expert” tabs to see the properties of the element
  • or I open the “interpreter” view and type “aql:self”. There you should see the object you select displayed as a result in the interpreter view, then when you add a dot “.” and hit Ctrl+Space, you should see the completion popup that lists all the methods you can call

With this information, you can infer the Java API. Let’s say you see a property called “ownedPhysicalComponents”; this means that you can call getOwnedPhysicalComponents() on the Java object.

I hope this helps.

1 Like