Author Topic: Solution: DiagramObject not positioned correctly  (Read 2180 times)

Eric Johannsen

  • EA User
  • **
  • Posts: 43
  • Karma: +0/-0
  • Model Driven Business[ch0174]
    • View Profile
Solution: DiagramObject not positioned correctly
« on: May 06, 2007, 09:01:34 pm »
I pulled my hair out for a bit on this one, so thought I would share the solution in case anyone else runs into the problem.

I'm creating a new diagram through automation, and found that all of the new DiagramObjects I was creating ended up in the upper-left corner of the diagram rather than where I tried to position them.

Here's a code fragment to illustrate the issue:

Code: [Select]

string position="l=0;r=100;t=200;b=300;"
EA.DiagramObject diagObj = (EA.DiagramObject)diagram.DiagramObjects.AddNew(position, "");
diagObj.ElementID = elem.ElementID;
diagObj.Update();


The PROBLEM was that I was positioning the left edge of my DiagramObject at zero (l=0).  Apparently the diagram starts at one (l=1) and passing a left coordinate of zero causes the positioning information to be ignored entirely.

To solve the positioning problem, use a left coordinate of at least one.

Eric
http://canoniccorp.com