I noticed that if you made a capella element outside a transaction, then opened a transaction and added that element under the architectureS of capella (OA,SA, ARCHI, PHYS), the item would not be added to all of them, except for the last one in the code. Obviousely this item has the same variable name (lets say var1), same capella name (elem1), and same capella type of course (type1), indeed the item was created one single time.
I tried to make a similar element in a new variable (var2,elem1,type1), INSIDE the transaction, and I noticed it had been taken in account.
I tried to separate one of the architectures from the rest and put in a new transcation. So I had:
On one hand a transaction that adds the same element (var1,elem1,type1) inside SA,ARCHI,PHY, and on the other hand a second transaction that comes BELOW the first transcation, and inside which we add the element (var1,elem1,type1) inside OA.
Result → The script added the element (var1,elem1,type1) in OA and nowhere else.
I also tried to just change the name of the capella element (var1,elem2,type1), before every modifying model querry, I still got only one single occurence, the three others ignored.
Finally I tried to give the variable containing the capella element, a new python value while keeping the same properties (var1,elem1,type1), before every modifying model querry, and it worked. Basically reinjecting the same properties of the var1 (var 1 = (elem1,type1)), or in other works, declare the python variable again.
- In Python4Capella, you cannot modify the model multiple times, with a single variable created onc single time outside a transaction (or not). Meaning, If you want to add an element created “once” (one single variable), in multiple places of your model, you cannot do it more than once.
- If you try to add that element in multiple places of your model anyway, then P4C will only take in account the very last occurence in the script, whether you call the adding query code in a single transaction multiple times, or in seperated transactions.
- However, if you re evaluate the value of the python variable just after a “modifying model query”, with the same properties, then you wil be able to use it again. As if the variable dissapeared once used by P4C to modify the model, and the only way to prevent it from dissapearing thus making it usable again, would be to reinject its value to the python variable, or in other words redeclare the variable.
So do you think it is supposed to be working this way, or is it some bug or? Thanks.
Ps.What i call “modifying model query” are the lines of code that take this form: se.get().add(…)