Book a Demo

Author Topic: Create diagram objects with variable positions  (Read 3194 times)

phamrt1

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Create diagram objects with variable positions
« on: October 17, 2008, 03:24:33 am »
I was able to create objects in a diagram using code like this:

DiagOb = (EA.DiagramObject)New_Diagram.DiagramObjects.AddNew("l=200;r=300;t=100;b=150;", "");

How do I replace the hard coded numbers (200,300,100,150) with variables so I can go through a loop and add multiple objects and place them in different positions in the diagram.  When I tried to assign values to the variables and use them in this code, the variables don't get used:

DiagOb = (EA.DiagramObject)New_Diagram.DiagramObjects.AddNew("l=Left;r=Right;t=Top;b=Bottom;", "");

I have multiple swimlanes created in the diagram.  Can I make the objects part of the swimlanes such that they can be positioned within the swimlanes?  For ex,  object 1 placed in Swimlane 1, object 2 placed in Swimlane 2...

Thanks


Chris Tatem

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Create diagram objects with variable positions
« Reply #1 on: October 17, 2008, 05:04:37 am »
Something like this *should* work.

String newStuff;
int Top = 100;
int Bottom = 150;
int Left = 10;
int Right = 110;
int shiftRight = 100;

[loop]
Left += shiftRight ;
Right += shiftRight;

newStuff = "l=" + Left + ";r=" + Right + ";t=" + Top + ";b=" + Bottom + ";";

DiagOb = (EA.DiagramObject)New_Diagram.DiagramObjects.AddNew(newStuff, "");

[endLoop]

I think this will move the objects left to right across your screen, in increments of 100.
or however you want to create the String outside the AddNew call.

phamrt1

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Create diagram objects with variable positions
« Reply #2 on: October 17, 2008, 06:57:45 am »
It worked  :).  Thanks a bunch!