The complete Enterprise Architect C# add-in template

In the post Tutorial: Create your first C# Enterprise Architect addin in 10 minutes you can find a basic template that can be used to create C# add-ins for Enterprise Architect.

But this basic template is far from complete. The EA API provides a whole set of  “events” that can be used in an add-in.
To use one of these events you have to create a public operation in the add-in class that contains the signature of the event. EA will then call that operation at the appropriate time so you can execute your behavior.

The problem is that the documentation of the EA API contains all of those operation signatures in VB syntax, so each time you want to use such an event in your C# add-in you’ll have to translate it to C# syntax.

To save myself the trouble each time I have to write a new add-in I created an abstract base class that contains all of the events defined by EA.

Usage instructions

  • Download the EAAddinBase.cs from the GitHub repository
  • Create a new class library project and add the EAAddinBase.cs to the project
  • Create a new add-in class that extends EAAddinBase.cs, see MyAddin.cs for inspiration
namespace MyAddin
{
    public class MyAddinClass : EAAddinFramework.EAAddinBase
    {
  • Override any EA event you wish to use. Typing “public override ” should get you a nice drop-down list of all available events, complete with documentation.

    Override EA Event drop-down
    Override EA Event drop-down
  • Follow the instructions in Tutorial: Create your first C# Enterprise Architect addin in 10 minutes in order to make your assembly COM Visible, register the assembly for COM Interop and create the registry key.
  • Build your project
  • Open up EA and test your add-in.

More resources

Related blog posts

Source code on GitHub

Sparx Systems

Other

  • Examples in the EA installation folder: C:\Program Files\Sparx Systems\EA\Code Samples