Accessing your favourite tool from within EA

I’m not sure if this is just me, but there are a few things that frustrate me when working within a tool such as EA.

  1. Firstly, there is often more information I want to view at the same time than is possible because I just don’t have enough screens! There is a potential solution to this.
  2. Secondly, is when I want to do a related task using a different tool, so need to switch context. This is frustrating especially when I have my head down producing stuff and I just want to press a button.  This may be unique to me but the need to switch to another tool, which is more about the need to go back to windows and select the program, open it and establish context etc

So is there a way to improve the situation by having the tools I want operate within the context of EA?  Let’s do a little exploration to check out what EA provides and see if it can help me.

1. EA Tool menu

First up, in looking at the tools menu there are shortcuts which start an external application, albeit in it’s own window but at least it is just a single click.

I think the standard installation comes pre-configured with a few tools:

  • MS Paint
  • ODBC sources
  • System information

And you can add any application to the EA tools menu.

EA tool menu - add your own tool

EA tool menu – add your own tool

To add an application you use the “Tools | Customize | Tools tab” to configure the application. You need to provide:

  • A command – the application you want to run
  • Arguments – and EA supplies a range of parameters that can be set and passed to the external application
  • Initial directory – this can be set but doesn’t appear to have any dynamic options.

As an example I use IrfanView for doing a lot of image manipulations. So I can add a new tool item to support my access to this tool within my working context.

Configure EA tool menu item to open IrfanView with clipboard

Configure EA tool menu item to open IrfanView with clipboard

You see I have set the application, however there are no parameters available from EA that make sense within the context of the IrfanView arguments. However, the reason I want to open IrfanView from within EA is usually to manipulate an image, hence if I assume that I have saved my desired image to the clipboard with EA (ctrl+B) and then add an IfranView argument “/clippaste” it will open with the current clipboard contents all ready for editing.

Although this is no major advance it does improve productivity when producing help documentation!

2. Using the EA parameters

So what applications could benefit from the arguments that are available from EA.  I needed to think about this as it wasn’t clear what applications other than something specifically written to work with EA would attribute meaning to the arguments – initial and final thought was that this is only useful for applications you write.  I am sure there are some really good examples, however none come to mind so I’ll just illustrate a simple application to demonstrate the use.

Below is the code for a simple console application which takes EA arguments, opens an instance of EA with the project file name provided and prints the name of the current package.

==== Code starts =====

class Program
public static void Main(string[] args)
// the arguments from EA will be the project name – which may have spaces so need to be wrapped in “‘s
// command line input
// arg 1 – EA project full path filename ($f)
// arg 2 – name of calling application ($F)
// arg 3 – current package ID ($p)
// arg 4 – current package GUID ($P)
// arg 5 – ID of associated diagram  ($d)
// arg 6 – GUID for associated diagram ($D)
// arg 7 – CSV of ID’s for all selected elements in current diagram ($e)
// arg 8 – CSV of GUID’s for all selected elements in current diagram ($E)

Console.WriteLine(“Number of command line parameters = {0}”, args.Length);
foreach( string a in args)
//            Console.Write(“Press any key to continue . . . “);
//            Console.ReadKey(true);

// open EA

Console.WriteLine(“\r\nProject file = ” + args[0]);
Console.WriteLine(“Openning EA, please be patient!”);
EA.Repository EAR = new EA.RepositoryClass();
EAR.OpenFile(args[0]); // open EA

// now just use one of the arguments to do some processing
int packID = Convert.ToInt32(args[2]);
if (packID != 0)
Console.WriteLine(“Package ID = {0}”, packID);
EA.Package p = EAR.GetPackageByID(packID);
Console.WriteLine(“Name of current package = {0}”, p.Name);
Console.Write(“Press any key to continue and close EA “);

===== code ends =====

So with the application written I use the EA customise to add my application to the tools menu.

EA Console Tool - example of an application that can handle EA arguments

EA Console Tool – example of an application that can handle EA arguments

And when run from my tools menu the output is as shown below.

Example output from the EA Console Tool test application

Example output from the EA Console Tool test application

As such this is an example that doesn’t do a lot other than illustrated that the mechanism works.  It is possible to call an external application and pass it information within the current user context – I repeat the current user context – as this is where the value will come.

A brief recap

In looking at accessing external tools I have reviewed how to existing tools as well as a custom tool.

In the case of the existing 3rd party tools, unless they are written specifically for EA, it is unlikely they can do much, although the ability to open my graphics application with the clipboard presented is really useful, and I am sure with some creativity there are some excellent use cases.

In the case that we have a custom application then we have a greater degree of freedom limited only by the application.  It provides the user with the ability to initiate some action within their current context.  I know I need to think about potentially other applications for this use case.


But can we bring our application closer?

In both these instances the access to out application is a manual process.  The user initiates the application.

In our custom application example we saw how the information provided to open a new instance of EA can be used to perform some operations.  Of course, our application could be used stand alone, i.e. without being called by EA, but in that instance we wouldn’t have the contextual information which was my starting point.

One downside is that our application runs as a separate entity and to access EA requires us to create a new instance, with the inherent start up time lag.  So is there a better way of adding functionality to EA as well as integrating with 3rd party tools.  The simple answer is yes – EA provides an AddIn framework which can address the shortfalls of working at “arms length” and I’ll come back to that in a future post.

In the meantime, I hope that this post has been interesting and at least made you think about how you use other tools with EA.  If you have any specific use cases that haven’t been covered please feel free to share your requests, ideas..