Issue creating new functions under other functions

I receive the following error when trying to add system functions under the Root System Function instead of alongside it:
at org.eclipse.emf.common.util.BasicEList$UnmodifiableEList.add(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at py4j.reflection.MethodInvoker.invoke(
at py4j.reflection.ReflectionEngine.invoke(
at py4j.Gateway.invoke(
at py4j.commands.AbstractCommand.invokeMethod(
at py4j.commands.CallCommand.execute(
at py4j.ClientServerConnection.sendCommand(
at py4j.CallbackClient.sendCommand(
at py4j.CallbackClient.sendCommand(
at py4j.reflection.PythonProxyHandler.invoke(
at com.sun.proxy.$Proxy30.executeScript(Unknown Source)
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.internalExecute(
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.execute(
at org.eclipse.ease.AbstractScriptEngine.inject(

This is the code which caused the issue, the variable new_FuncNames is just a list of Strings:
for value in new_FuncNames:
# create a SystemFunction
sf = SystemFunction()
#set its name
print("* Create a new system function with name " + value )
#add the new SystemFunction
OwnedFunc = se.get_system_analysis().get_system_function_pkg().get_owned_system_functions().get(0).get_contained_system_functions()
# if something went wrong we rollback the transaction
# if everything is ok we commit the transaction

# save the Capella model

The SystemFunction.containedSystemFunctions is a derived reference (it is computed), so you can’t modify its value. For the moment the API for modifying the Capella model is far from complete, but you can add the following method to the SystemFunction class in the file:

    def get_owned_functions(self):
        return create_e_list(self.get_java_object().getOwnedFunctions(), Function)

Then you can call it like this:

OwnedFunc = se.get_system_analysis().get_system_function_pkg().get_owned_system_functions().get(0).get_owned_functions()

I don’t think the final API will look like this, but it’s a workaround until we release the corresponding API.

Thank you for your help! Is there an easy way to tell what is a derived reference and what is a standard java method for the class?

In the simplified API specification the reference should be marked as read only. If you have the Capella source code in your environment, you can check the comment of the method:

 * Returns the value of the '<em><b>Contained System Functions</b></em>' reference list.
 * The list contents are of type {@link}.

 * <!-- begin-user-doc -->
 * <p>
 * If the meaning of the '<em>Contained System Functions</em>' reference list isn't clear,
 * there really should be more of a description here...
 * </p>
 * <!-- end-user-doc -->
 * @return the value of the '<em>Contained System Functions</em>' reference list.
 * @see
 * @model transient="true" changeable="false" volatile="true" derived="true"
 *        annotation=" viatra.variant='alias' viatra.expression='ownedFunctions'"
 *        annotation=" feature='ownedFunctions'"
 *        annotation=" UML/SysML\040semantic\040equivalences='keyword::none' explanation='Derived and transient' constraints='none'"
 * @generated

In the model tag, you can see derived=“true”.

Also the stack in your first post shows:

java.lang.UnsupportedOperationException at org.eclipse.emf.common.util.BasicEList$UnmodifiableEList.add(

Which happen only if the reference is read only or is derived.