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.

34 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
  17. 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
  18. Hey there! Do you know if they make any plugins to assist with Search Engine Optimization? I’m trying to get my website to rank for some targeted keywords but I’m not seeing very good results.
    If you know of any please share. Cheers! I saw similar
    art here: Escape room

    Reply
  19. I’ve been browsing on-line more than three hours nowadays, but I by no means found any fascinating article like yours. It is pretty value sufficient for me. In my opinion, if all site owners and bloggers made good content material as you did, the net will probably be a lot more helpful than ever before!

    Reply
  20. Hey there! Do you know if they make any plugins to help with Search
    Engine Optimization? I’m trying to get my website to
    rank for some targeted keywords but I’m not seeing very good results.
    If you know of any please share. Thank you! I saw similar text here

    Reply
  21. I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

    Reply
  22. Thanks for the sensible critique. Me and my neighbor were just preparing to do some research about this. We got a grab a book from our local library but I think I learned more clear from this post. I’m very glad to see such excellent info being shared freely out there.

    Reply
  23. Great article and right to the point. I don’t know if this
    is really the best place to ask but do you guys
    have any thoughts on where to get some professional writers?
    Thx 🙂 Escape room

    Reply
  24. You have mentioned very interesting points! ps nice site.?

    Reply
  25. It is appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I wish to suggest you some interesting things or advice. Maybe you could write next articles referring to this article. I wish to read more things about it!

    Reply
  26. great issues altogether, you simply won a brand new reader. What would you recommend about your publish that you just made some days in the past? Any certain?

    Reply
  27. Having read this I believed it was rather enlightening. I appreciate you spending some time and energy to put this information together. I once again find myself spending a lot of time both reading and commenting. But so what, it was still worthwhile!

    Reply
  28. I’m amazed, I have to admit. Seldom do I encounter a blog that’s both educative and amusing, and without a doubt, you’ve hit the nail on the head. The problem is something that too few folks are speaking intelligently about. Now i’m very happy I found this in my search for something concerning this.

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

    Reply
  30. Wonderful blog! I found it while browsing on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thanks

    Reply
  31. Fantastic article. I discovered the information highly useful. Appreciated the method you detailed the content.

    Reply
  32. Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me. https://accounts.binance.com/fr/register-person?ref=GJY4VW8W

    Reply
  33. Adored the details in this entry. It’s very detailed and full of useful insights. Fantastic effort!

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

    Reply

Leave a Comment

*