Recently I was trying to set aggregation connectors between elements using scripting. Durring the process I realized I cannot set direction as well as Subtype (weak vs strong). While debugging my code I separated behaviour I want to describe below. I'm curious it's a bug or I'm missing something down the road.
There is a test case.
1. Create simple diagram with 2 class elements: Class1 and Class2.
2. Create aggregation by dragging connector from Class2 to Class1 and selecting "Composition to Part". Name it whatever you want. The result should look like the picture:
3. Run following script, entering GUIDs of Class2 and the Diagram, before you run:
!INC Local Scripts.EAConstants-JScript
/*
* Script Name:
* Author:
* Purpose:
* Date:
*/
function main()
{
var el as EA.Element;
var diagram as EA.Diagram;
el = Repository.GetElementByGuid('GUID of Clas2 element');
diagram = Repository.GetDiagramByGuid('GUID of diagram');
for (var i=0; i<el.Connectors.Count; i++)
{
Session.Output(el.Connectors.GetAt(i).Name );
Session.Output(el.Connectors.GetAt(i).Direction);
el.Connectors.GetAt(i).Update(); // this line changes direction
Session.Output(el.Connectors.GetAt(i).Direction);
}
Repository.ReloadDiagram(diagram.DiagramID);
}
main();
4. The result on my end looks like on picture bellow. The direction of aggregation is changed from Source->Destination to Destination->Source. Debug console confirms it also
Also I don't understand why position of element Class2 has been changed by reloading diagram.
What am I doing wrong?