Author Topic: Left, right, top and bottom properties of DiagramObject  (Read 6888 times)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Left, right, top and bottom properties of DiagramObject
« Reply #15 on: February 12, 2020, 02:01:06 am »
What do you mean with "this works"? Now you're acutally supplying b/r which you initially didn't.

q.

MatthiasVDE

  • EA User
  • **
  • Posts: 196
  • Karma: +1/-0
    • View Profile
Re: Left, right, top and bottom properties of DiagramObject
« Reply #16 on: February 12, 2020, 02:21:26 am »
What do you mean with "this works"? Now you're acutally supplying b/r which you initially didn't.

q.

It prints the correct right and bottom values, as displayed on the diagram.

         Session.Output messageRootObject.right
         Session.Output messageRootObject.bottom

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Left, right, top and bottom properties of DiagramObject
« Reply #17 on: February 12, 2020, 02:59:07 am »
Well, again: your OP left bottom/right empty. Here you seem to supply them.

q.

MatthiasVDE

  • EA User
  • **
  • Posts: 196
  • Karma: +1/-0
    • View Profile
Re: Left, right, top and bottom properties of DiagramObject
« Reply #18 on: February 12, 2020, 06:33:24 pm »
Well, again: your OP left bottom/right empty. Here you seem to supply them.

q.

No I didn't.

Recap:
When you add an element to a diagram (diagramobject), you need to provide left, right, top, bottom. But when the element (for example a class) is too large (many attributes and long names), and you provide right = 20 and bottom = 40, then the real size of the element overrides the values that you provide for right and bottom, this is the same effect as when you do not provide anything. When you take a look on the diagram, you will see that the right and bottom values are different than those you provide (or didn't provide if you left it blanco).

But:
When you read the values right and bottom of the diagramObject, you will determine that they are equal to those you provide (or didn't provide if you left it blanco).

Right?

To solve this problem, I did the following:

Code: [Select]

dim l, r, t, b
l = "20"
r = "" --> If I put 30 here, the effect on the diagram is the same
t = "20 "
b = "" --> If I put 40 here, the effect on the diagram is the same               
dim messageRootObject as EA.DiagramObject
set messageRootObject = messageDiagram.DiagramObjects.AddNew("l="&l&";r="&r&";t="&t&";b="&b, "")
messageRootObject.ElementID = element.ElementID
--> the element is a class with a long name and many attributes

Code: [Select]
messageRootObject.Update()
Repository.OpenDiagram(messageDiagram.DiagramID)

--> look at the diagram, the right and bottom are not "zero", neither "30" or "40" if you provided this. This is because the element has long names and too many attributes for those right and bottom values.

When you read the values right and bottom from your diagramobject at this point, you will see 'zero' or '30' or '40', but not the values as displayed on your diagram.
But if you want to read them, you need the following workaround, otherwise it doesn't work.

Code: [Select]
Repository.SaveDiagram(messageDiagram.DiagramID)
--> First open it before you can save it

Code: [Select]
Repository.ReloadDiagram(messageDiagram.DiagramID)
messageDiagram.DiagramObjects.Refresh()
--> This code is also needed, otherwise I doesn't work.

Code: [Select]

dim newMessageRootObject as EA.DiagramObject
for each newMessageRootObject in messageDiagram.DiagramObjects
     if newMessageRootObject.ElementID = element.ElementID then
set messageRootObject = newMessageRootObject
     end if
next
--> This is also necessary

Code: [Select]

Session.Output messageRootObject.right
Session.Output messageRootObject.bottom
Now you see the values, based on the real size as displayed on the diagram.
« Last Edit: February 12, 2020, 06:36:06 pm by MatthiasVDE »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Left, right, top and bottom properties of DiagramObject
« Reply #19 on: February 12, 2020, 07:45:15 pm »
Now I see. Another weird EA hack indeed. I also tried parts of that but not in the exact combination (I wasn't that desperate as you ;-). I'll play around a bit more later...

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Left, right, top and bottom properties of DiagramObject
« Reply #20 on: February 12, 2020, 08:37:56 pm »
Interestingly for me it does not work (most likely a version issue). I noticed that the size of the newly created diagram object varies depending on the use of save/reload and its order. Well, as long as it works for you... For me I'll close Pandorra's jar.

q.

MatthiasVDE

  • EA User
  • **
  • Posts: 196
  • Karma: +1/-0
    • View Profile
Re: Left, right, top and bottom properties of DiagramObject
« Reply #21 on: February 12, 2020, 08:42:03 pm »
Interestingly for me it does not work (most likely a version issue). I noticed that the size of the newly created diagram object varies depending on the use of save/reload and its order. Well, as long as it works for you... For me I'll close Pandorra's jar.

q.

I use 15.1

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Left, right, top and bottom properties of DiagramObject
« Reply #22 on: February 12, 2020, 09:40:22 pm »
I'm on 13.5. Who knows what happened.

q.