EA addin c# CustomProperties - change the activity parameter direction value

352 views Asked by At

I try to change CustomProperties sets for element, and I have some questions/problems, could anyone to help me? 1. I added a new element and checked CustomProperties sets for this element in t_xref -> not found, none rows for this t_object.ea_guid. 2. I added two elements and set value for direction to "in" for first and "out" for secound. -> I read (in foreach) all settings CustomProperties sets (?) for this elements, try to change one of them (direction), and update elements. Still I have nothing in t_xref for this t_object.ea_guid. In GUI it's shown that this CustomProperties are set to these same values for all elements like settings value for the last element in update in foreach ("out"). When I saved (in GUI) showed parameters for this element, rows is added to t_xref. Do You know, where is mistake in my code? I have no idea...

EA.IDualElement elementActivity = null;
elementActivity = element.Elements.AddNew("Activity1", "Activity");
elementActivity.Update();

EA.IDualElement elementActivityParameter = null;
var position = String.Format("l={0};r={1};t={2};b={3};", 0, 0, 0, 0);

//add 1. element ActivityParameter
elementActivityParameter = elementActivity.Elements.AddNew("ActivityParameter1", "ActivityParameter");
elementActivityParameter.ClassifierID = 123 //ElementID
elementActivityParameter.Update();
elementActivity.Update();
//change CustomProperty
foreach (EA.CustomProperty prop in elementActivityParameter.CustomProperties)
 if (prop.Name == "direction") prop.Value = "in";
elementActivityParameter.Update();
elementActivity.Update();
//add to diagram
EA.IDualDiagramObject diagramObject1 = diagram.DiagramObjects.AddNew(position, string.Empty);
diagramObject1.ElementID = elementActivityParameter.ElementID;
diagramObject1.Update();

//add 2. element ActivityParameter
elementActivityParameter = elementActivity.Elements.AddNew("ActivityParameter2", "ActivityParameter");
elementActivityParameter.ClassifierID = 123 //ElementID
elementActivityParameter.Update();
elementActivity.Update();
//change CustomProperty
foreach (EA.CustomProperty prop in elementActivityParameter.CustomProperties)
 if (prop.Name == "direction") prop.Value = "out";
elementActivityParameter.Update();
elementActivity.Update();
//add to diagram
EA.IDualDiagramObject diagramObject2 = diagram.DiagramObjects.AddNew(position, string.Empty);
diagramObject2.ElementID = elementActivityParameter.ElementID;
diagramObject2.Update();
0

There are 0 answers