Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: lostwald on March 14, 2013, 03:12:58 am

Title: Port positioning via C# AddIn
Post by: lostwald on March 14, 2013, 03:12:58 am
Hi,

I'm trying to position ports of a component via AddIn using C#. After getting the corresponding EA.DiagramObject of a port I modified the top, bottom, left, right attributes.
After calling the Update() method of the port, the parent EA.DiagramObject (the component with the ports) and the Update() method of the diagram the port is not moved to the desired location but to a location in the upper left (not the top left corner) of the component.
The set location would be valid if I would position it by UI with the mouse.
How can I position a port correctly ?

Thanks in advance.
Title: Re: Port positioning via C# AddIn
Post by: Geert Bellekens on March 14, 2013, 06:34:30 pm
Two things to check

- Did your updates really go through? Do you see the changed values in the database
- Did you reload the diagram after your updates?

Geert
Title: Re: Port positioning via C# AddIn
Post by: qwerty on March 14, 2013, 08:18:14 pm
Positioning of embedded elements is broken in V10.
Quote
We have been able to reproduce the scenario described in your report and
this will be investigated further by our development team.

Your reference number for this issue is 13024568.

Unfortunately we cannot provide any schedule for this issue to be
resolved as yet.  If you wish to request the status of this issue at a
later time, please quote the above reference number in your enquiry.


It worked in 9.3 so you might go back to that version.

q.
Title: Re: Port positioning via C# AddIn
Post by: McMannus on June 06, 2013, 09:01:31 am
Since I also had to cope with this problem, I finally mastered it (works also in v10):

Code: [Select]
public static void putPortInDiagram(EA.Repository rep, EA.Element port, ElementLayout layout, int diagramID)
{
    EA.Diagram diagram = rep.GetDiagramByID(diagramID);
    EA.DiagramObject newDiagObject = diagram.DiagramObjects.AddNew(layout.getEAPosString(), "");
    newDiagObject.ElementID = port.ElementID;
    newDiagObject.Update();
    string sql = "UPDATE t_diagramobjects " +
                 "SET RectLeft="+layout.getRectLeft()+", RectRight="+layout.getRectRight()+", RectTop="+layout.getRectTop()+", RectBottom="+layout.getRectBottom()+
                 " WHERE Diagram_ID="+diagramID+" AND Object_ID=" + port.ElementID;
    rep.Execute(sql);
}
where layout.getRectRight() etc. are just int values as you would use them in AddNew().
Title: Re: Port positioning via C# AddIn
Post by: qwerty on June 06, 2013, 09:40:10 am
One of these work-arounds  ::) We're just hackers and used to it  ;)

q.