How to add Enumeration under a specific data package?

Hello
I want to add Enumeration elements by scripts.
The Enum could be initialized by class Enumeration from capella.py. The problem I met was I could not get the proper e_list of a specific data package to accommodate the Enumeration. The class DataPkg seems not to provide method for enumerations, while get_owned_classes works for Class elements.
Is there any way to add Enumerations under a named data package?

You can use the ownedDataTypes EStructuralFeature:

myDataPkg.get_java_object().getOwnedDataTypes().add(myEnumeration.get_java_object())

I added an issue to add this API:

@YvanLussaud Thanks. I moved forward to add Property to Class element. I tried to use class_element.get_java_object().getOwnedFeatures().add(propery_element.get_java_object()). It could work but leave “undefined” with Min/MaxCard, which looks like the only difference with manually added properties.
Could you tell me how to add min/max card as default as 1? Or Is there a better way to address this propery addition process?

I’m not sure it will help in your case… But there is a method that can handle addition of elements to the Capella model once they are attached to the model:

org.polarsys.capella.core.model.helpers.CapellaElementExt.creationService(addedElement.get_java_object())

You can see an example here. Make sure you change the name and any other features after calling this method. To remove the error on the org symbol not beeing recognize by the PyDev editor, you can add the org symbol using this documentation.

To manually add cardinalities, you can use:

minCard = LiteralNumericValue()
minCard.get_java_object().setValue('1')
propery_element.get_java_object().setOwnedMinCard(minCard.get_java_object())

maxCard = LiteralNumericValue()
maxCard.get_java_object().setValue('1')
propery_element.get_java_object().setOwnedMaxCard(maxCard.get_java_object())

I opened an issue to add missing setters to the API.