Blog Post

Execute Enterprise Architect Scripts from an External Program

We can execute Enterprise Architect Scripts from an external C# Application. Enterprise Architect supports a flexible and easy to use scripting capability. Enterprise Architect supports three scripting languages JavaScript and Microsoft JScript/VBScript.

Pros

  • 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

Cons

  • Certain limitations within scripts discussed in the article below.

Assumptions

  • 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
    • To create an Addin from scratch refer this link 
    • Download Skeleton for creating an Add-In using the C# Language from this link

How to invoke Scripts from an External Application

  • Create an application and get a handle of Enterprise Architect

select script.ScriptID as SCRIPTID, script.Notes as NOTES, script.ScriptName as SCRIPTNAME, script.Script as SCRIPTGroup from t_script script where script.ScriptAuthor IS NOT NULL

  • 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;
scriptController.AddObject(“Repository”, Session.Repository);
//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
try
{
//first add the included code
string includedCode = IncludeScripts(scriptcontent); //pass script content string
//then add the included code to the scriptcontroller
scriptController.AddCode(includedCode);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
  • 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

Limitations

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
    • “Session”.Eg.Session.Output,Session.Input,Session.Prompt
  • 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 info@sparxsystems.in for any assistance.

16 Comments

  1. When you forget the password to lock the screen, if you do not enter the correct password, it will be difficult to unlock and gain access. If you find that your boyfriend/girlfriend is suspicious, you may have thought about hacking his Samsung phone to get more evidence. Here, we will provide you with the best solution on how to crack Samsung mobile phone password.

    Reply
  2. If you are thinking of using a cell phone spy app, then you have made the right choice.

    Reply
  3. Your article helped me a lot, is there any more related content? Thanks!

    Reply
  4. Wow, incredible weblog structure! How lengthy have you been blogging for?
    you made running a blog glance easy. The full
    look of your website is great, as well as the content! You can see similar here ecommerce

    Reply
  5. Howdy, I do believe your blog could be having browser
    compatibility issues. Whenever I look at your blog in Safari, it looks fine however when opening in IE, it has some overlapping issues.
    I simply wanted to give you a quick heads up! Aside from that,
    great blog! I saw similar here: Sklep online

    Reply
  6. Just want to say your article is as amazing. The clarity in your post is just excellent and i could
    assume you are an expert on this subject. Fine with your permission allow me to
    grab your RSS feed to keep updated with forthcoming
    post. Thanks a million and please carry on the gratifying work.
    I saw similar here: Najlepszy sklep

    Reply
  7. Howdy, i read your blog occasionally and i own a similar one and i was just wondering if you get a
    lot of spam feedback? If so how do you protect against it,
    any plugin or anything you can advise? I get so much lately it’s
    driving me insane so any assistance is very much appreciated.
    I saw similar here: Sklep

    Reply
  8. Keep on writing, great job! I saw similar here: E-commerce

    Reply
  9. Hi there! Do you know if they make any plugins to help
    with SEO? I’m trying to get my blog to rank for some targeted keywords but
    I’m not seeing very good success. If you know
    of any please share. Thanks! You can read similar article here: Sklep

    Reply
  10. Hi! Do you know if they make any plugins to assist with SEO?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good gains.

    If you know of any please share. Cheers! You can read similar article here: Sklep

    Reply
  11. Hi there! Do you know if they make any plugins to assist with SEO?

    I’m trying to get my blog to rank for some targeted
    keywords but I’m not seeing very good gains.
    If you know of any please share. Thank you! I saw similar blog
    here: Backlink Portfolio

    Reply
  12. Your article helped me a lot, is there any more related content? Thanks!

    Reply
  13. Wow, marvelous blog layout! How long have you been running a blog
    for? you made running a blog look easy. The total glance of your web site is excellent, as well as the content material!
    You can see similar here najlepszy sklep

    Reply
  14. Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.

    Reply
  15. Thanks for sharing. I read many of your blog posts, cool, your blog is very good.

    Reply
  16. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

    Reply

Leave a Comment

*