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:
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
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.
Repository.SaveDiagram(messageDiagram.DiagramID)
--> First open it before you can save it
Repository.ReloadDiagram(messageDiagram.DiagramID)
messageDiagram.DiagramObjects.Refresh()
--> This code is also needed, otherwise I doesn't work.
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
Session.Output messageRootObject.right
Session.Output messageRootObject.bottom
Now you see the values, based on the real size as displayed on the diagram.