Author Topic: Creating profiled elements  (Read 1862 times)

William McKenzie

  • EA User
  • **
  • Posts: 61
  • Karma: +0/-0
    • View Profile
Creating profiled elements
« on: May 26, 2011, 11:06:08 pm »
I want to create a new element for a specific profile (Archimate) in script.  I can set the Stereotype correctly, and I can add tagged values, but EA still doesn't seem to know that it is an Archimate element.

Code: [Select]
var testElement as EA.Element;
            testElement = elements.AddNew( "Upstream Business Management", "Activity" );
            testElement.Stereotype = "ArchiMate_Function";
            TVSetElementTaggedValue( testElement, "iconstyle", false, true);
            TVSetElementTaggedValue( testElement, "functiontype", "Business", true);
            testElement.Update();

What else do I need to do to make it appear using the correct symbol, etc. when I drag it on a diagram.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7301
  • Karma: +86/-12
    • View Profile
Re: Creating profiled elements
« Reply #1 on: May 27, 2011, 08:45:40 am »
Try:

Code: [Select]
var testElement as EA.Element;
testElement = elements.AddNew( "Upstream Business Management", "ArchiMate::Function" );
testElement.Update();
Eve

support@sparxsystems.com

William McKenzie

  • EA User
  • **
  • Posts: 61
  • Karma: +0/-0
    • View Profile
Re: Creating profiled elements
« Reply #2 on: May 27, 2011, 01:19:42 pm »
Excellent!  That did it.

Thanks,

~Bill

Rudi Claes

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Creating profiled elements
« Reply #3 on: July 10, 2012, 09:38:34 pm »
A small update on this one: the ArchiMate namespace prefix has to be present in order to resolve ambiguity. From an OO perspective, this is a common approach.

With an Archimate Function, there is no problem:

(1) elements.AddNew( "XYZ", "ArchiMate::Function" );
(2) elements.AddNew( "XYZ", "Function" );

will produce the same result, an ArchiMate Function for (1) and (2)

However, there is a problem with an ArchiMate Component:

(3) elements.AddNew( "XYZ", "ArchiMate::Component" );
(4) elements.AddNew( "XYZ", "Component" );

will produce a different result: an Archimate Component for (3), but a UML component for (4)

Adding a stereotype does not help:

(5) elements.AddNew("XYZ", "Component", "ArchiMate_Component" );
(6) elements.AddNew("XYZ", "Interface", "ArchiMate_Interface" );

will get you a UML Component (5) / Interface (6), that is stereotyped as an ArchiMate one. This is not wat you want.

To be in sync with elements / connectors that you drag & drop from the toolbox, use the stereotype in combination with the namespace prefix:

(7) elements.AddNew("XYZ", "ArchiMate::Component", "ArchiMate_Component" );
(8) elements.AddNew("XYZ", "ArchiMate::Interface", "ArchiMate_Interface" );

will produce the expected results.

Regards,

Rudi

qwerty

  • EA Guru
  • *****
  • Posts: 11471
  • Karma: +304/-263
  • I'm no guru at all
    • View Profile
Re: Creating profiled elements
« Reply #4 on: July 10, 2012, 11:47:07 pm »
Quote
(5) elements.AddNew("XYZ", "Component", "ArchiMate_Component" );
(6) elements.AddNew("XYZ", "Interface", "ArchiMate_Interface" );
of course, because AddNew accepts only two parameters. The third is ignored.

q.

Rudi Claes

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Creating profiled elements
« Reply #5 on: July 11, 2012, 01:03:52 am »
Indeed. I used a wrapper function in which the third argument was assigned to the stereotype attribute.

So the following statements:

(5) elements.AddNew("XYZ", "Component", "ArchiMate_Component" );
(6) elements.AddNew("XYZ", "Interface", "ArchiMate_Interface" );
(7) elements.AddNew("XYZ", "ArchiMate::Component", "ArchiMate_Component" );
(8) elements.AddNew("XYZ", "ArchiMate::Interface", "ArchiMate_Interface" );

Should be read as:

(5) newElement = pkg.elements.AddNew("XYZ", "Component")
newElement.stereotype = "ArchiMate_Component"

(6) newElement = pkg.elements.AddNew("XYZ", "Interface")
newElement.stereotype = "ArchiMate_Interface"

(7) newElement = pkg.elements.AddNew("XYZ", "ArchiMate::Component")
newElement.stereotype = "ArchiMate_Component"

(8) newElement = pkg.elements.AddNew("XYZ", "ArchiMate::Interface")
newElement.stereotype = "ArchiMate_Interface"

Thanks for the correction.

Regards,

Rudi

qwerty

  • EA Guru
  • *****
  • Posts: 11471
  • Karma: +304/-263
  • I'm no guru at all
    • View Profile
Re: Creating profiled elements
« Reply #6 on: July 11, 2012, 01:18:37 am »
One more remark: if you create an element via AddNew and supplying a metatype from a profile like Archimate::Component it receives the correct stereotype from the profile. I would not additionally assign the stereotype once again.

q.