Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: dangel on September 05, 2015, 08:38:20 am
-
Is there any SDK explains how can I update some tagged value Types in my Enterprise Architect Project, using API C# coding
Thanks
-
I did the following code but no effects on EA Tagged Value Types
EA.TaggedValue XX = new TaggedValue();
XX.Name = "XX";
XX.Notes = "ZZ";
XX.Value = "AZ";
XX.SetAttribute("XX", "ZZ");
XX.Update();
=======================================
an error occurred , no results :(
(http://s14.postimg.org/ap5mvvgcx/image.jpg)
-
You cannot create tagged values like that. You have to add it to an element.
EA.TaggedValue MyTaggedVal = MyElement.TaggedValues.AddNew("XX","");
Geert
-
Thanks for your replay, I am developing an EA-Tool in order to extract some information from EA.Repository, but I want to insert new Tagged Value Types to the repository not only to the elements, and later on I will call a function to link that Tagged Value to all elements in my diagram.
So is there any API to add/insert global Tagged Value Types from my Add-Ins.
Thanks
-
You mean the Default Tagged Values from the Tagged Values window?
q.
-
yes :)
-
There is no API. You need to put them into t_propertytypes via Repositroy.Execute
q.
-
Try the Repository.PropertyTypes collection.
-
The code that Geert gave is proper one.
Here you have a method that I wrote for adding TaggedValues to the element:
private bool addTaggedValue(EA.Element req, string tagName)
{
TaggedValue tag = req.TaggedValues.GetByName(tagName);
if (tag == null)
{
const string defaultValue = "";
var element = req.TaggedValues.AddNew(tagName, defaultValue);
element.Update(); //must be executed in order to save new tagged value
req.Update(); // is it needed?
return true;
}
return false;
}
the AddNew method comes from Collection API (link nr 4).
I also recommend those help files for you to uderstand what is going on:
1. http://www.sparxsystems.com/enterprise_architect_user_guide/12/automation_and_scripting/element.html
2. http://www.sparxsystems.com/enterprise_architect_user_guide/12/automation_and_scripting/element2.html
3. http://www.sparxsystems.com/enterprise_architect_user_guide/12/automation_and_scripting/taggedvalue.html
4. http://www.sparxsystems.com/enterprise_architect_user_guide/12/automation_and_scripting/collection.html
-
I had the same problem to solve and Simon solution is the only correct for this question.
Thanks Simon!
Try the Repository.PropertyTypes collection.