Sparx Systems Forum
Enterprise Architect => Bugs and Issues => Topic started by: StefanBrandmeier on November 13, 2023, 07:28:52 pm
-
Hello EA community,
I am trying to evaluate tagged values inside of the code generator of EA.
Using the tagged value substitution macro I try
$tagName = "test"
$tagValue = %classTag:"$tagName"%
Unfortunately the variable $tagName is not evaluated and the $tagValue stays empty.
If I replace the variable with a literal of the tag name then it works.
Is this a bug or a missing feature ?
Thanks for any help
Cheers
Stefan
-
You could call it a missing feature. The language only supports a string literal in that location, you're asking for a tag with the name "$tagName".
You can achieve the same effect with a call to an add-in: %EXEC_ADD_IN("MyAddIn","GetTag",classGUID,$tagName)%
-
Hi Eve and thanks for your quick reply !
I was not aware of this macro. I will have to look up how the create the "MyAddIn" ?
Any example you can point me to ?
Checking the documentation I don't see the possibility to code an add-in as a JScript in my script library.
Do I really have to create a DLL in a foreign IDE in order to get this "missing" feature ?
Thanks
Stefan
-
Yes, and add-in requires a COM compabitible dll.
I have published a tutorial on how to create add-ins and stuff on my website: https://bellekens.com/writing-ea-add-ins/ (https://bellekens.com/writing-ea-add-ins/)
Geert
-
You can also create a model add-ins.
https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/modeladdins.html (https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/modeladdins.html)
-
Hello Eve,
I did manage to find my way into the model add-ins and added some behaviour code, see below.
Can I just code this in JScript for example and use the Add-In with the macro you mentioned above ?
Thanks
Stefan
var elem as EA.Element;
var tag as EA.TaggedValue;
var tags as EA.Collection;
elem = Repository.GetElementByID(elementID)
tags = elem.TaggedValues;
tag = tags.GetByName(tagName);
return tag.Value;