1
votes

I am working in Enterprise Architect C# add-ins. I need to arrange the elements and connectors through code such that there is no overlapping of connectors. I have set the Line Style as Auto Routing for the diagram links.

Is there a API available in EA for setting the starting point/ending point of connector as source element's dimension value such that the connector starts from the top of the element.

Kindly Help. Thanks in advance.

Edit:I have tried updating through API as follows but am not able to see change in connector starting position:

            for (short i = 0; i < Diagram.DiagramLinks.Count; i++)
            {

                    EA.DiagramLink dl = Diagram.DiagramLinks.GetAt(i);
                    //set the line style and update
                    dl.LineStyle = EA.LinkLineStyle.LineStyleAutoRouting;
                    dl.Geometry = "EDGE=4;";
                    dl.Update();
                    Diagram.Update();
            }
1

1 Answers

2
votes

This is possible, but tricky. DiagramLinks have an attribute Geometry which holds a csv styled list. A detailed description can be found in my Inside book, but you can simply look for parameters SX and SY which specify the relative X and Y positions and they can vary +- half width/height of the start object. Analogously EXand EY for the end. Finally the EDGE parameter specifies the edge from where the connector starts at the start object: 1=bottom; 2=left; 3=top; 4=right

Edit1: I fiddled around a bit, but I have no open mind at the moment. What you should do is to create an empty EAP and place two two elements on a diagram and connect these. Now run SELECT geometry FROM t_diagramlinks in the SQL scratch pad. Move the connector/elements around, save the diagram (or the changes will not be written to the database) and re-issue the SQL to see the effect on SX etc.

Also, you can update Geometry via the API which is what I'd recommend. Further you need to reload the diagram to see the updates reflected in the graphics.

Edit2: Probably the answer to your issue. The Edge attribute is just a r/o attribute. Important are the coordinate parameters. So if you want to have the connector start at the middle top edge you need to set SX=0;SY=<halfheight>; where <halfheight> is half of the element height. Also note that you can provide values which are out of bounds and EA will just render funny results (means they do not check the validity of the attribute on Update()).

This has been my test code (sorry for the Perl ;-):

my $d = $rep->GetCurrentDiagram();
for my $dl (in $d->DiagramLinks) {
  print $dl->Geometry . "\n";
  $dl->{Geometry} = 'SX=0;SY=10;EX=0;EY=0;';
  $dl->Update();
}
$rep->ReloadDiagram($d->DiagramId);

P.S. The edge is always determined upon the relative positioning of the connected elements (unless connector ends are pinned).