Book a Demo

Author Topic: Create Archimate elements into Grouping element  (Read 5355 times)

rmartinezb

  • EA User
  • **
  • Posts: 44
  • Karma: +1/-0
    • View Profile
Create Archimate elements into Grouping element
« on: March 06, 2017, 11:04:14 pm »
Hi!

I'm trying to create programmatically some archimate elements into an ArchiMate_Grouping element. I'm doing that replacing the parentID of the element for the elementID of the grouping element.
In the Project Browser, the elements appears into the grouping element, but this is not reflected in the diagram.

How can I represent this in the diagram?

PD: I have tried to create the DiagramObjects before and after replacing the parentID.
« Last Edit: March 06, 2017, 11:37:58 pm by rmartinezb »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create Archimate elements into Grouping element
« Reply #1 on: March 07, 2017, 01:43:26 am »
Things like that are not reflected in a diagram automatically. You need to remove the old element from the diagram first and create the new one on the place of the old one.

q.

rmartinezb

  • EA User
  • **
  • Posts: 44
  • Karma: +1/-0
    • View Profile
Re: Create Archimate elements into Grouping element
« Reply #2 on: March 07, 2017, 02:55:09 am »
Hi qwerty,

I'm not sure I have understood you. I don't want to replace any element, and if i had to replace some, put the new one in the old place won't solve anything, wasn't it?

Also I tried some test like:
Code: [Select]
            Collection elements = thePackage.Elements;
            Element groupingElement;
            groupingElement = elements.AddNew("Grouptest", "Archimate2::ArchiMate_Grouping");

            Element test;
            Collection groupElements = groupingElement.Elements;
            test = groupElements.AddNew("test", "Archimate2::ArchiMate_Node");

            EA.DiagramObject dObject = diagram.DiagramObjects.AddNew(groupingElement.Name, "Archimate2::ArchiMate_Grouping");
            dObject.ElementID = groupingElement.ElementID;
            dObject.Update();

            dObject = diagram.DiagramObjects.AddNew(test.Name, "Archimate2::ArchiMate_Node");
            dObject.ElementID = test.ElementID;
            dObject.Update();

            diagram.Update();

Create first the grouping element, create the test element directly into grouping element and then create the diagram objects, but still doesn't work.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create Archimate elements into Grouping element
« Reply #3 on: March 07, 2017, 08:45:26 am »
You need to supply the diagram position of the new element like
Code: [Select]
dia_obj = diagram.DiagramObjects.AddNew ("l=10;r=110;t=-20;b=-80", "");I'm pretty sure, that your addNew just fails (or the update where you should check the boolean return value).

q,