Saturday, 15 April 2017 20:35

Use C#, Java, for your VB Scripting

Written by
Rate this item
(0 votes)

 Use C#, Java from your EA Context Menu:

This works for all EA Versions, even without Administration rights to install an Add-In or so.

EA Version 13 supports an IDE to develope in C# and Java with full EA API support and debugging. They name it Hybrid Scripting. You may use the EA 13 Hybrid Script environment or other IDEs. Going the first steps is easier with EA 13.

This article shows you with a little example how to use C# for your Scripting. After you have understood C#, it should be easy to use Java in a similar way. The main idea is to use a small wrapper you call within your VB Script. Of course, after you have understood it's also easy to write this little wrapper for JavaScipt/JScript. 

SPARX delivers two DLLs to use the EA API efficiently. With these DLLs, you can use the EA Hybrid development environment as well as any other IDE you like most. In other words: You can use the power of state of the art languages to perform your scripting. Integrating Scripting in EA is as easy as you know it from the well-known Scripting Languages VB Script, JavaScript, JScript. This without installing anything or needing Admin rights.

Just insert the line:

  • 'RunCommand("myLogic.exe, "", " ")'

in your VB Script and you are done with VBScript to call your C#. Java would be similar.


Let's make a quick example with EA Version 13 and C#:

Make an EA C# ConsoleApplication

  • Create a new EA Project
  • Create a Package ('Select and Apply Model Pattern')
    • C#, RepositoryInterface 4.0
    • c:\temp\hybrid
  • Build the Application
  • Have a look in the generated Application
    • c:\temp\hybrid\RepositoryInterface 4.0\


Import VBScript wrapper to call C# 

  • Configure, Transfer, Import Reference Data
  • Make EA Scripting visible 
    • Code, Scripting (you may have to refresh Scripts)
  • You see the new VB Scripts inside the ScriptGroup HybridScripting:
    • RunCommand
    • RunCommandTest


Run C# ConsoleApplication.exe

  • Adapt VBScript RunCommandTest
    • Adapt path to 'ConsoleApplication.exe'
  • See
    • Line:28/29 Needed references
    • Line:35      Path to *.exe which executes your logic
    • Line:36      The call of the wrapper, result contains the StandardOutput of the Script
  • Run VBScript RunCommandTest
    • Right Click on RunCommandTest
    • Run Script


How do you use it

There are two approaches: Generates you VB Script by inserting the the wrapper Call in the EA templates at the appropriate location. The other way is to remove the template and just call the wrapper like

'result = RunCommand("myLogic.exe, "", " ")'

instead of the using the template scuffold.

Under the hood

EA delivers the two dlls:

  • Interop.EA.dll
  • SparxSystems.Repository.dll

They expect the Process ID, first parameter, to know which EA Instance the *.exe wants to use. So, RunCommands makes:

  • Estiminate the own Process ID
  • Call 'RunCommand...'
  • Reads the Standard output from your *.exe
  • Returns to Standard output to the caller

Inside the *.exe you have full access to the EA API.

JavaScript, JScript, Java?

With this example it's easy to migrate 'RunCommand' to JavaScript or JScript. Remember, you can use every Language supported by EA and every IDE you like most.



Read 8326 times Last modified on Friday, 21 July 2017 00:38
Helmut Ortmann

Helmut Ortmann

Freelancer (Consultant)
I'm a German freelancer in the area of Enterprise Architects and software/system engineering. A large part is embedded and Functional Safety with EA. But not only...
According to Albert Einsteins aphorism "Make things as simple as possible, but not simpler” I like to smoothen work with Addins and an easy to use EA Tool integration in a complex development environment. Another step in my opinium are lively workshops to get an enjoyable and long lasting launch of the daily EA work.
Well, of course that’s not all and you have therefore good reasons to contact me. See you….
See my hoTools WiKi at GitHub.
Login to post comments