- Hassle-free updates in restricted environments – Not necessary to re-install addins
- Introduce new feature in less time – Create New functionality using Scripts
- Deploy changes to all model users -Scripts are stored in repository
- Scripting is an interesting feature in Sparx Enterprise Architect. This aid us to do many things using Scripts and play with the active models
- Certain limitations within scripts discussed in the article below.
- The reader has a fairly good understanding of creating an Enterprise Architect Addin or writing an application that can use Enterprise Architect. Refer to below references if you need more information on these
How to invoke Scripts from an External Application
- Create an application and get a handle of Enterprise Architect
- Execute above Query to get the set of Script information
- Parse the XML Output to get the Script Content based on Script Name and Guid by user selection
- Save this script content in a string and pass as an argument for IncludeScripts method
- Use ScriptControlClass to invoke the Enterprise Architect script.
Refer below code
|ScriptControlClass scriptController = new ScriptControlClass();|
scriptController.Language = this.language.name;
scriptController.Timeout = -1;
//Add the actual code. This must be done in a try/catch because a syntax error in the script will result in an exception from AddCode
//first add the included code
string includedCode = IncludeScripts(scriptcontent); //pass script content string
//then add the included code to the scriptcontroller
catch (Exception e)
- Add Reference for ScriptControlClass to invoke Enterprise Architect selected scripts.
- Set AddObject to Active Enterprise Architect repository.
- Replace all the !INC with actual codes in scriptcontent
Script should not include any Enterprise Architect specific keywords.
- It should not use “as”
- Correct Syntax : Var ele;
- Incorrect Syntax : Var ele as EA.Element;
- Script should not use any static functions like
- Repository and !INC are the only Enterprise Architect specific keywords supported
Certainly, users could develop an external program to handle scripts inside EA. Please drop your comments below if you have any queries.
Drop mail to firstname.lastname@example.org for any assistance.