Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Doubter on February 09, 2023, 02:36:42 am

Title: Creating model elements from outside EA
Post by: Doubter on February 09, 2023, 02:36:42 am
Hello!

I am working with a SysML model and I want to create a few things in the model from outside EA. It's mostly Values that I want to create for already existing blocks in the model. The Values should be connected to a ValueType and have a Default Value.

Now I'm thinking about, what is the best way to this. As I already work a lot with a XML-Export of said SysML model, I was thinking about editing and adding the values in the XML file and import it afterwards. The other option I was wondering about is if EA has a programming interface that can import data and create model elements.

Does someone maybe have already done something like that or can help me getting started with this?
I'd love to hear all the advice and feedback I can get as I didn't really manage to find anything yet on how to facilitate this.

Thank you!
Thomas
Title: Re: Creating model elements from outside EA
Post by: Geert Bellekens on February 09, 2023, 03:22:16 am
Hi Thomas,

Yes, EA has an API that you can use to do almost anything, including importing things.
The documentation for the API starts here: https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/theautomationinterface.html (https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/theautomationinterface.html)

If you are looking for other examples than the ones in the documentation, you can have a loot at my github repo's
https://github.com/GeertBellekens/Enterprise-Architect-Toolpack (https://github.com/GeertBellekens/Enterprise-Architect-Toolpack)
https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library

Geert
Title: Re: Creating model elements from outside EA
Post by: qwerty on February 09, 2023, 05:58:22 am
You probably want to look into EAAttribute.Default to set the default values. It's a collection of an element's attributes retrievable via EAElement.Attributes.

q.
Title: Re: Creating model elements from outside EA
Post by: Mauricio Moya (Arquesoft) on February 09, 2023, 07:41:33 am
If you are going to develop an external app, lets say, a console C# in Visual Studio, you have to check the compilation mode (32 or 64 bits) according to the version of EA you are using. Note that after version 16 you have both 32 and 64 bits options, and before v16 only 32 bits available.
Title: Re: Creating model elements from outside EA
Post by: Geert Bellekens on February 09, 2023, 10:17:02 am
If you are going to develop an external app, lets say, a console C# in Visual Studio, you have to check the compilation mode (32 or 64 bits) according to the version of EA you are using. Note that after version 16 you have both 32 and 64 bits options, and before v16 only 32 bits available.
You can simply compile in AnyCPU, that works with both 32 and 64 bit EA installations.

Geert
Title: Re: Creating model elements from outside EA
Post by: Doubter on February 10, 2023, 02:12:42 am
Thank you all very much for your replies!
I will look into it and get back here if I have any more questions.

Best regards
Thomas