Author Topic: Code Template - classTag with variable tag name does not work  (Read 3891 times)

StefanBrandmeier

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Code Template - classTag with variable tag name does not work
« 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

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Code Template - classTag with variable tag name does not work
« Reply #1 on: November 14, 2023, 08:23:18 am »
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)%

StefanBrandmeier

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Code Template - classTag with variable tag name does not work
« Reply #2 on: November 17, 2023, 01:14:13 am »
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
« Last Edit: November 17, 2023, 01:23:22 am by StefanBrandmeier »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Code Template - classTag with variable tag name does not work
« Reply #3 on: November 17, 2023, 01:27:16 am »
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/

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile

StefanBrandmeier

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Code Template - classTag with variable tag name does not work
« Reply #5 on: December 20, 2023, 09:57:30 pm »
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;