Book a Demo

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

Examples and Tips

Points to consider

Subject

Points

See also

Examples

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 WordTM documentation is available from the internet at  sparxsystems.com/resources/developers/autint_vb.html
  • Additional samples are available from the Sparx Systems website; see the Available Resources topic
Call from Enterprise Architect Code Samples sparxsystems.com/resources/developers/autint_vb.html Available Resources

Tips and Tricks

Also note these 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 and 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 (see 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
Repository Class App Object

Enterprise Architect Not Closing

After all processing by an automation controller is complete, it is recommended to call CloseFile() and Exit() on the Repository object, then set all references to the repository object to null.

     repository.CloseFile();

     repository.Exit();

     repository = null;

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:

     GC.Collect();

     GC.WaitForPendingFinalizers();

There are additional concerns when controlling a running instance of Enterprise Architect that loads Add-Ins - see the Tricks and Traps topic for details.

Tricks and Traps