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.
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
- 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:
Run C# ConsoleApplication.exe
- Adapt VBScript RunCommandTest
- Adapt path to 'ConsoleApplication.exe'
- 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:
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.
- SPARX Webinar Hybrid Scripting
- SPARX Tutorial Hybrid Scripting
- hoTools Hybrid Scripting
- RunCommand.vbs (The wrapper to call your C#, Java,..)
- RunCommandTest.vbs (An Example with EA example C# Hybrid Script ConsoleApplication.exe, see Tutorial )