Author Topic: Port Layout  (Read 7601 times)

martin1

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Port Layout
« on: April 09, 2014, 11:07:25 pm »
Hi,
I created a diagram using the automation interface for C#. The elements on the diagram contain ports. The problem is, that those ports are stacked one upon the other. Is there a possibility to arrange those ports in a nice way around the element?

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Port Layout
« Reply #1 on: April 10, 2014, 12:41:22 am »
Hello,

you may write a script or an Addin to do this. Don't do it for EA10 because it will not work.

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Port Layout
« Reply #2 on: April 10, 2014, 02:05:48 am »
Partially it seems to work in V10. If the ports are already there you can modify the position in DiagramObjects and save the changes. Creating new DOs will result in wrong positions. In V11 (and 9.3/before) this function works as expected.

q.

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Port Layout
« Reply #3 on: April 10, 2014, 02:47:01 am »
Thanks q,

there is always something to learn.

Helmut

Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

martin1

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Port Layout
« Reply #4 on: April 10, 2014, 03:28:34 am »
Quote
Partially it seems to work in V10. If the ports are already there you can modify the position in DiagramObjects and save the changes. Creating new DOs will result in wrong positions. In V11 (and 9.3/before) this function works as expected.
q.

When is a DO considered "already there" and when is it considered new?

I assume new means right after creation and insertion into the Diagram Element Collection. Does "already there" mean I have to open and close the diagram in EA? (so that positions are refreshed or something other magically happens ;))

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Port Layout
« Reply #5 on: April 10, 2014, 04:09:52 am »
"There" means it has been created before (by hand) and you just want to move it around the legal borders. If you create the embedded DO via API in V10 it gets places somewhere top left of the embedding element. No matter what your supplied coords say. That's only wrong in V10. You don't need to have the diagram open to run the script.

q.

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Re: Port Layout
« Reply #6 on: April 16, 2014, 07:49:06 am »
Port Positioning is also possible completely automatic in V10.
Let's see, how:

The precondition for it is that a reference to an element is at hand. This could either be gotten from a hand-created element or from an add-in created element that is not in any diagram by now.
Note that, layout.getEAFormattedLayoutString() returns the EA position string like "l=10;r=110;t=-20;b=-80".

It is important that this information is written again to the t_diagramobjects table, because that is exactly the point where EA doesn't work correctly in V10.

Code: [Select]
           
public static void putElementInDiagram(IDualRepository rep, IDualElement element, SimpleElementLayout layout, int diagramID)
{
            EA.Diagram diagram = rep.GetDiagramByID(diagramID);
            Collection diagObjects = diagram.DiagramObjects;
            DiagramObject newDiagObject = diagObjects.AddNew(layout.getEAFormattedLayoutString(), "");
            newDiagObject.ElementID = element.ElementID;
            newDiagObject.Update();
            EALayout eaLayout = layout.getEALayout();
            string sql = "UPDATE t_diagramobjects " +
                         "SET RectLeft=" + eaLayout.rectLeft + ", RectRight=" + eaLayout.rectRight + ", RectTop=" + eaLayout.rectTop + ", RectBottom=" + eaLayout.rectBottom +
                         " WHERE Diagram_ID=" + diagramID + " AND Object_ID=" + element.ElementID;
            rep.Execute(sql);
            rep.GetDiagramByID(diagramID).DiagramObjects.Refresh();
            diagObjects.Refresh();
}

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Port Layout
« Reply #7 on: April 16, 2014, 08:37:11 am »
Well, lesson learned :) But I guess it's recommended to use the (now again) working API from V11 instead of the backdoor SQL ;)

q.

martin1

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Port Layout
« Reply #8 on: February 18, 2015, 09:51:50 pm »
Any update on this in EA 12? Is there a way to layout diagrams and diagram objects neatly?

m

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Port Layout
« Reply #9 on: February 18, 2015, 10:25:20 pm »
I just made a short test and it seems they fixed it.

q.

martin1

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Port Layout
« Reply #10 on: February 20, 2015, 01:05:20 am »
Thanks for information.

What do you consider the best way to layout a diagram neatly? Any add-on?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Port Layout
« Reply #11 on: February 20, 2015, 01:09:09 am »
Well, that's not a trivial task. I once wrote a Perl script to layout ports. It was something like: a) many ports in one direction -> space even; b) two opposed ports -> align 2nd selected to first. This was fairly easy to implement and helped hugely with the layout.

q.