Tutorial

LAPTOP-N364A3DK\helmu edited this page Dec 30, 2018 · 18 revisions

Tutorial

This tutorial shows you:

  • How C# Scripts called from EA VB Scripts are working
  • How to develop your own C# scripts
  • The knowledge to use other languages like Java, VB, F#, C++

This tutorial assumes you are using Visual Studio 2017. You may use other IDEs. For Java see Java.

Installation

See Installation

Quick start

  • Unzip EaScripts.zip to your Script folder (eg. c:\<myProductive>\<MyEaScriptFolder>)
  • Set User Environment Variable
    • EA_SCRIPT_HOME=c:\<myProductive>\<MyEaScriptFolder>\
  • Start EA Repository: ScriptDotNet.eap
  • Launch Script

EA

The repository we work with:

  • ScriptDotNet.eap

DEBUG

You can debug your code with VS / your IDE. You have to:

  • Build in DEBUG mode
  • Launch a Script, see Launch
  • After the Script reaches the Debug Dialog Box
    • Attach VS to ScriptDotNet.eap
    • Debug

Prerequisites

  • Ensure Project Debug Properties:
    • Start external program
      • C:\Program Files (x86)\Sparx Systems\EA\EA.exe
  • Environment Variable 'EA_SCRIPT_HOME' set to the debug\bin folder
    • SETX EA_SCRIPT_HOME c:\MyVsSolutionPath\ScriptCSharp\bin\Debug\
    • Adapt and run ScriptCSharp\Scripts\SetEnvDebug.bat
    • Restart Visual Studio
  • EA: Script Windows
    • Specialize, Scripting
  • EA: Output Windows
    • Portals, Windows, System Output or
    • Find Command 'Output'

EA Debug settings

Debug Settings

EA Script Windows

VB Scripts

DEBUG Session

  • You: Build solution in DEBUG mode
  • You: Restart Visual Studio
  • You: Set breakpoints
  • You: Run Debug mode
  • VS: Opens EA
  • You: Open EA Repository 'ScriptDotNet.eap'
  • You: EA: Browser, Specialize, Traverse Package
  • EA: Follow instruction
    • VS Attach to Process 'ScriptCSharp.exe'

Attach VS 2017 to ScriptCSharp.exe

Attach to Process

Launch

This description uses the delivered ScriptDotNet.eap Repository.

VB Script
  • Include ScriptCSharp
    • !INC ScriptDotNet.RunCommandVb ' to include ScriptCSharp
  • Call CSharp
    • runCommand "%EA_SCRIPT_HOME%ScriptCSharp.exe", "ListDiagramElements", currentDiagram.DiagramGUID ' Call
    • runCommand "%EA_SCRIPT_HOME%ScriptCSharp.exe", "TraversePackage", thePackage.PackageGUID ' Call
    • runCommand "%EA_SCRIPT_HOME%ScriptCSharp.exe", "ModelSearch" ' Call, everything is done in C#, contect item contains the row in ModelSearch
Launch from Project Browser

Run Script TraversePackage from Browser Results Script

Launch from Diagram

ListDiagramElements

Glossary

  • VS Visual Studio 2017

References

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.