Examples and Tips
Instructions for using the interface are provided through sample code. There are several sets of examples:
- VB 6 and C# examples are available in the Code Samples folder under your Enterprise Architect installation (default: C:\Program Files\Sparx Systems\EA\Code Samples)
- Enterprise Architect can be set up to call an external application
- Several VB.NET code snippets are provided in the reference section
- A comprehensive example of using Visual Basic to create MS Word documentation is available from the internet at www.sparxsystems.com/resources/developers/autint_vb.html
- Additional samples are available from the Sparx Systems website; see the Available Resources topic.
Additionally, you should note the following tips and tricks:
- An instance of the Enterprise Architect (EA.exe) process is executed when you initialize a new repository object. This process must remain running in order to perform automation tasks. If the main window is visible, you can safely minimize it, but it must remain running.
- The Enterprise Architect ActiveX Interface is a functional interface rather than a data interface. When you load data through the interface there is a noticeable delay as Enterprise Architect user interface elements (such as Windows, menus) are loaded and the specified database connection is established.
- Collections use a zero-based index; for example, Repository.Models(0) represents the first model in the repository.
- During the development of your client software your program might terminate unexpectedly and leave EA.exe running in such a state that it is unable to support further interface calls. If your program terminates abnormally, ensure that Enterprise Architect is not left running in the background (see the Windows Task Manager / Process tab).
- A handle to a currently running instance of Enterprise Architect can be obtained through the use of a GetObject() call. For more information, refer to the reference page for the App object. Accessing your Enterprise Architect model via the App object enables querying the current User Interface status, such as using GetContextItem() on the Repository object to detect the current selection by the user, allowing for rapid prototyping and testing.
Enterprise Architect Not Closing
If your automation controller was written using the .NET framework, Enterprise Architect does not close even after you release all your references to it. To force the release of the COM pointers, call the memory management functions as shown below:
There are additional concerns when controlling a running instance of Enterprise Architect that loads Add-Ins - see the Tricks and Traps topic for details.