Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: vrieg on June 15, 2023, 04:17:11 am
-
Hello all,
we have an UML Profile, that we recently extended by MetaConstraints and StereotypedRelationships between Elements. We use both for Toolboxes and ModelValidation.
However we would also use some scripts for input automation and to perform model transformations.
After adding MetaConstraints and StereotypedRelationships to the MDG, neither AddElement nor AddPackage does work.
Did someone have similar issues or an idea what could be the root cause? For our scripts we use both Python and C# via EA API.
-
What do you mean by AddElement or AddPackage?
I don't know these methods.
If you share the code that is misbehaving we might have a clue about what is going on.
Geert
-
sorry I meant AddNew() for elements, packages and diagrams.
meanwhile I found out, that in the mdg a metatype has been added to the stereotypes.
as the AddNew() is based on checks using .type of the element, package, diagram the scripts require some adaptions.
our fault then but actually not completely obvious
-
You can use the fully qualified stereotype name in the AddNew operations
e.g. Package.Elements.AddNew("MyComponent", "ArchiMate3::ArchiMate_ApplicationComponent") (there might be typos in the fully qualified stereotype in this example)
That avoids rework when you change the base type of your stereotypes elements.
The only caveat is when you have a stereotype can be applied to multiple basetypes (such as BPMN intermediate events). In that case you'll get one type, but maybe not the one you really wanted.
Geert