Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: eric.meredith on April 13, 2018, 07:41:29 am

Title: Automation: Capabilities in Capabilities
Post by: eric.meredith on April 13, 2018, 07:41:29 am
Appreciate any help I can get.

I have used the Excel Importer extensively to import Server Objects, Applications, and to create multi-level packages - so I'm familiar with the API interface.

I need to automate the insertion (later update) of Capabilities. Some of these will be decomposed into sub-Capabilities. From a UI perspective I can do everything I want/need, but with automation, I'm not even sure how to ask the right questions.

Yet, "Capabilities within Capabilities" leaves me blank. See this link for an example: https://drive.google.com/file/d/18Fyq6lBsjgLyNaKcl7Ef12oFcuqLNuRV/view?usp=sharing (https://drive.google.com/file/d/18Fyq6lBsjgLyNaKcl7Ef12oFcuqLNuRV/view?usp=sharing)

tldr; What API do I use to add a Capability within an existing Capability.

Thx,
Eric
Title: Re: Automation: Capabilities in Capabilities
Post by: Nizam on April 13, 2018, 08:41:26 am
tldr; What API do I use to add a Capability within an existing Capability.

If I understand your question right, you may need two things
1. Get the GUID of your current capability (Use the Excel Exporter to get that) and try to synchronize in subsequent imports
2. Set the ParentID of Element (child capability) to create Capabilities within an existing Capability (Get the Parent Element by using GetElementByGUID)
Title: Re: Automation: Capabilities in Capabilities
Post by: Rich Anderson on April 13, 2018, 02:27:05 pm
I would recommend that you try creating a simple VB.Net program using Visual Studio Community Edition that reads the spreadsheet directly through the Excel API and then updates the EA model directly using the EA API.  In this way, you can bypass the whole problem of Excel importing.  You can just write a loop that goes down the rows and/or columns of the spreadsheet and plugs the elements and connectors into EA.  I do this all the time and have done some quite complex importing that way.
Title: Re: Automation: Capabilities in Capabilities
Post by: eric.meredith on April 13, 2018, 11:51:37 pm
Nizam - thanks, I will try - haven't used the ParentID thingy before.
Rich - I am not using an "Excel Import" per se - I am using VBA (effectively VB) to programmatically create and manipulate objects. I just didn't know how to create a child of a Capability.

Thanks to both for your replies.
Eric
Title: Re: Automation: Capabilities in Capabilities
Post by: qwerty on April 14, 2018, 12:43:40 am
You can just create elements in elements by using
Code: [Select]
newElement = Element.Elements.AddNew("name", "yourmetatypeorstereotype")
q.