Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Paulus on September 06, 2012, 08:34:47 am

Title: Running scripts from add-in?
Post by: Paulus on September 06, 2012, 08:34:47 am
I would like to execute a script when certain events occur, like e.g. the EA_OnPreNewElement.

I know that the usual way to do this would be to create an add-in but i'm not that familiar with MS tooling like VS C#, or the C# language & libraries for that matter. I could make the effort to master this but i prefer not to and stick to writing VB/Javascript.

Has anyone tried something like this before, is there a way around MS VS/C#?





Title: Re: Running scripts from add-in?
Post by: KP on September 06, 2012, 09:03:32 am
You can write add-ins in C++, Java, Delphi, Perl, anything that can create COM objects. I reckon that VB6 is the easiest language to write add-ins if you can find an old copy (MS stopped selling it many years ago). But if you are worried about the learning curve involved in writing C# add-ins, there is a working example in the resources section of this site somewhere (http://www.sparxsystems.com/bin/CS_AddinFramework.zip) that will give you a very good start.
Title: Re: Running scripts from add-in?
Post by: Geert Bellekens on September 06, 2012, 04:20:39 pm
Paulus,

I think the only way to use the events is to write an add-in.
I would really to be too afraid of it. C# is really a good language (pretty much the same thing as Java), and if you don't like VS you can use SharpDevelop (http://www.icsharpcode.net/OpenSource/SD/) (which is open source, free and a lot leaner then VS)
I've written some blog posts about creating add-in's for EA that might interest you:

Tutorial: Create your first C# Enterprise Architect addin in 10 minutes (http://geertbellekens.wordpress.com/2011/01/29/tutorial-create-your-first-c-enterprise-architect-addin-in-10-minutes/)
The complete Enterprise Architect C# add-in template (http://geertbellekens.wordpress.com/2011/02/16/the-complete-enterprise-architect-csharp-add-in-template/)
Testing and debugging your Enterprise Architect C# Add-In (http://geertbellekens.wordpress.com/2011/02/08/testing-and-debugging-your-enterprise-architect-csharp-add-in/)
Tutorial: Deploy your Enterprise Architect C# add-in with an MSI package (http://geertbellekens.wordpress.com/2011/02/23/tutorial-deploy-your-enterprise-architect-csharp-add-in-with-an-msi-package/)

Examples:
- Simple: MyAddin (https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/tree/master/MyAddin)
- Complete: EA Navigator (https://github.com/GeertBellekens/Enterprise-Architect-Toolpack/tree/master/EANavigator)

I'm not sure though if or how you can run scripts from the add-in; I don't really use scripting.

Geert
Title: Re: Running scripts from add-in?
Post by: Paulus on September 06, 2012, 06:35:44 pm
Thanks guys for the advice & samples! I'm going to look into it.

Still i think it would be a nice addition to EA if one could write scripts against all the events that are available to add-ins. I know it isn't rocket-science but writing scripts is a lot simpler since, apart from EA, you don't need any additional knowledge & tooling. I think that would be a big plus for companies that have more java-oriented ICT departments!

Any chance that there will be a future extension to the scripting capabilities of EA in that respect? I mean, a mechanism that allows for registering custom scripts to run in response to EA events?