Author Topic: Port positioning via C# AddIn  (Read 3506 times)

lostwald

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Port positioning via C# AddIn
« 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +564/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Port positioning via C# AddIn
« Reply #1 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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Port positioning via C# AddIn
« Reply #2 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.

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Re: Port positioning via C# AddIn
« Reply #3 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().
« Last Edit: June 06, 2013, 09:04:01 am by McMannus »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Port positioning via C# AddIn
« Reply #4 on: June 06, 2013, 09:40:10 am »
One of these work-arounds  ::) We're just hackers and used to it  ;)

q.