Search code examples
c#add-inenterpriseenterprise-architect

Creating Read-Only tagged Value in enterprise architect through c# add-ins


I am currently working on add-in where I need to create read-only tag values through code. The default way to add tagged values Element.TaggedValues.AddNew("Value", "")creates tagged values of type string only. I read that defining Type=Const creates read-only tagged values but when I tried Element.TaggedValues.AddNew("Value", "Const"),it creates tagged values of type string only. Kindly help.Thanks in advance.


Solution

  • There 's a difference between adding a tagged value and adding a tagged value Definition.

    To add a tagged value definition use something like

    EA.PropertyType taggedValueType = EA.Repository.PropertyTypes.AddNew("myTagName","");
    taggedValueType.Description = "some description";
    taggedValueType.Detail = "Type=Const;"+Environment.Newline+"Default=Val;";
    taggedValueType.Update();
    

    Then add a tagged value of your type using

    Element.TaggedValues.AddNew("myTagName","")