Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: AlexY on June 20, 2011, 10:19:39 pm

Title: How to create TOGAF add-in element with script?
Post by: AlexY on June 20, 2011, 10:19:39 pm
QUESTION: I want the elements created by script to have TOGAF add-in properties. How can I do this? Thanks.
(Background information is below).


I use TOGAF add-in and need to import many elements representing physical application components.

The TOGAF add-in has a special element "PhysicalApplicationComponent" in toolbox intended to represent physical application - see image below..
(https://docs.google.com/uc?id=0B9JQ3l_ccG4kMzg2NzUwZDMtMWEyNy00MDQwLTgyNDYtN2NjNjYzYzk1ZmJk&export=download&authkey=CLGb3K8H&hl=en_GB)


The element has a set of TOGAF properties defined as tags - see the image below..
(https://docs.google.com/uc?id=0B9JQ3l_ccG4kZTkzZWIwNzktYmFjYy00NzFkLWE5YjItMmYzOTMzOTZmMGYz&export=download&authkey=CMmK4okD&hl=en_GB)


When add elements with script:
Code: [Select]
var thePackage as EA.Package;
var elements as EA.Collection;
var element as EA.Element;

thePackage = Repository.GetTreeSelectedPackage();
elements = thePackage.Elements;      
element = elements.AddNew( "Created by script", "Component" );
element.Stereotype = "PhysicalApplicationComponent";


The element created does not have TOGAF properties..
(https://docs.google.com/uc?id=0B9JQ3l_ccG4kYTk0Njk4MzktNzE3ZS00MGJkLTk5NmItNzVlMmMzODNhYWIy&export=download&authkey=CLmDkqQO&hl=en_GB)


So, how to create an element which will have the TOGAF properties as defined by the TOGAF add-in?

Title: Re: How to create TOGAF add-in element with script
Post by: Luis J. Lobo on June 20, 2011, 11:51:03 pm
Change the line:

element = elements.AddNew( "Created by script", "Component" );

to:

element = elements.AddNew( "Created by script", "TOGAF::PhysicalApplicationComponent" );
Title: Re: How to create TOGAF add-in element with script
Post by: AlexY on June 21, 2011, 12:56:32 am
Yes, it worked! Thanks, Luis.