Book a Demo

Author Topic: Creating diagram connectors  (Read 4531 times)

Jeremie0

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Creating diagram connectors
« on: July 06, 2015, 06:07:03 pm »
Hi everybody,
I'm trying to create links from actors to usecases in a usecase diagram

The code works for the first usecase, but crashes on the second one...

Code: [Select]
EA.Connector connect = usecase.Connectors.AddNew("", "UseCase");
connect.ClientID = usecase.ElementID;
connect.SupplierID = actor.ElementID;

connect.Update();

i tried switch clientid and supplierid but no luck so far

anyone has a solution ?
thanks a lot

Jeremie0

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Creating diagram connectors
« Reply #1 on: July 06, 2015, 07:03:11 pm »
Nevermind i fixed it, it was because you cannot create connectors with a element.Type notes

Now other problem, i cannot place the objects as i want even though i specified the positionX and positionY

Code: [Select]
                   EA.Collection diagramObjects = diagram.DiagramObjects;
                    EA.DiagramObject diagramObject = diagramObjects.AddNew(usecase.Name, "otDiagramLink");
                    diagramObject.ElementID = usecase.ElementID;
                    diagramObject.DiagramID = diagram.DiagramID;
                    usecaseguid = usecase.ElementGUID;

                    diagramObject.top = 200 + (75 * i);
                    diagramObject.left = 560;
                    diagramObject.right = 560 + 100;
                    diagramObject.bottom = 140 + (75 * i);

                    diagramObject.Update();
                    diagram.Update();
                    diagramObjects.Refresh();
                    i++;

                    usecase.Update();

Takeshi K

  • EA User
  • **
  • Posts: 632
  • Karma: +43/-1
    • View Profile
    • Sparx Systems Japan
Re: Creating diagram connectors
« Reply #2 on: July 06, 2015, 07:18:13 pm »
EA's Y-axis value is negative, so you need to change like the following:

 diagramObject.top  = -140 - (75 * i);
 diagramObject.bottom= -200 - (75 * i);

HTH,
--
t-kouno