Book a Demo

Author Topic: Incorrect values for DiagramObject position  (Read 5110 times)

Willi Nesensohn

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Incorrect values for DiagramObject position
« on: July 18, 2012, 11:41:55 pm »
Hi!

We're automating EA 9.3.933 to create diagrams and layout those utilizing Interop.EA from a .NET application.

First, the automation creates the elements of the diagram and the DiagramObjects and saves the diagram. It does not set any values for width/height/position. After that, it layouts the diagram.

Most of the time this works as expected, but sometimes the position information in the DiagramObjects is just plain wrong (it really looks like uninitialized memory), resulting in a wrong layout as we rely on this information (and have to, since we don't know any way to trigger the "Autosize" functionality by COM-Interop).

These bogus values can also be found in the .eap file in t_diagramobjects, and EA updates them to their correct values some time after creating the diagram. The problem is that this time-span appears to be non-deterministic, so we can't rely on the values at all.

Is there a way to trigger the update of these values via COM, so that they get corrected, or is there another way to get reliable size information from the diagramobjects?

Thanks so much in advance,
Willi

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Incorrect values for DiagramObject position
« Reply #1 on: July 19, 2012, 12:23:46 am »
If I understand right you are creating the diagram objects. In that case you should set the size information along with the creation. Just place them top left and stretch them as appropriate.

q.

Willi Nesensohn

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Incorrect values for DiagramObject position
« Reply #2 on: July 19, 2012, 01:06:28 am »
Hi,

thanks for replying.

However, we would like to use EAs ability to automatically size the elements, as the size of an element depends on many factors which we can not query via COM (such as font size, certain configuration values which change class appearance, ...), making it quite difficult, if not impossible, to come up with the perfect size for every element. EA has this ability, since it uses it whenever you place an item interactively, we've just found no reliable way to utilize it.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Incorrect values for DiagramObject position
« Reply #3 on: July 19, 2012, 06:29:05 am »
What I found out is that after creation the random size information goes directly to the database (t_diagramobjects). EA however seems to recognize these as invalid and renders the object top left. When auto-layout is run all positions are re-assigned. And for the random values the size is also re-assigned (all other elements keep their size).

Now I tried to set the size of the new element to 100,000 in square - which made EA crash when opening the diagram. I ended up with the insight that EA recognizes those  new objects via the invalid (positive) y-coordinate.

My best guess: ask for a feature that emulates auto-size.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Incorrect values for DiagramObject position
« Reply #4 on: July 19, 2012, 03:46:56 pm »
Hi Willi,

I would try a combination of open/close/auto-layout/save/refresh of the diagram until you can be sure that EA has saved the correct values.
Usually there is some (often twisted :-X) logic to how and when these values get updated.

Geert

Willi Nesensohn

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Incorrect values for DiagramObject position
« Reply #5 on: July 20, 2012, 03:08:14 am »
Hi Geert,

thanks for your hints!

We're already doing doing some combinations of open/close/save/refresh (also DiagramObjects.Refresh), although without auto-layout, which improved the situation while not resolving it completely - we'll continue to find out the correct sequence to resolve this issue reliably.

Willi

Willi Nesensohn

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Incorrect values for DiagramObject position
« Reply #6 on: September 26, 2012, 07:15:14 pm »
Hi!

Just wanted to let you know that we now perform the following steps, yielding great results so far:

Autolayout with LayoutDiagramEx
Let EA handle outstanding events (Application.DoEvents() in C#)
Save & close the diagram
Remove the custom paths from all diagramlinks by doing a sql update on t_diagramlinks' path column.

The last step is necessary because the auto layout engine may introduce custom paths.