Hybrid Scripting in Enterprise Architect 13
This example will illustrate
how to access model information using C
sharp as a scripting language
The goal of this demonstration is to use
Hybrid Scripting to list each and every
package that is included in an EA
Example Model. The model pattern includes
the diagram to help you build and debug
your hybrid script. The class contains
the corresponding C Sharp script.
The system output window indicates when the
application has been build and
identifies any errors in the build process.
Once you run the application and
system output window is used to display
the title process ID and/or the package
names that appear in the project browser.
Now let's look at how you create the
script from an existing model pattern.
Creating a Hybrid Script using a model
pattern in Enterprise Architect 13.
Open the model was from the 'Design'
ribbon.
From the application patterns tab select
C-sharp followed by repository interface 3.5
Select a suitable destination folder
to store your C sharp code and click OK
Hybrid Scripting is provided to extend
the capabilities of standard scripting
environment to high-level languages such
as Java and C sharp.
This sample program
demonstrates how easy it is to navigate
query and report on the current model
using any Microsoft .Net language.
To use script by selecting the class on
the diagram and then press f12.
From the execute Ribbon, I will access the
breakpoints window to help me to debug my
application. I also need to open the
Execution Analyzer Window in order to
access my analyzer scripts. Ensure the
repository interface build configuration
has been selected.
Switching back to our
diagram we have the tools to build the
project with the results being displayed
in the system output window.
Exit with code zero indicates that no errors were
found in the script.
When we run the project.
We can see all the packages in
the EA Example Model being displayed on screen
Now let's step through and debug our
code to better understand how it works.
I'll start by clearing the system output window.
I'm going to break execution at
lines 28, 37, 47 and 67 .
Line 128 contains their
first trace statement that indicates
that the application is running.
Line 47 print the process ID, and the other
breakpoints allow us to observe the
printing process. You can use a breakpoint
set to group and manage your breakpoints.
The Execute Ribbons help us
simplify the process of stepping through
your code one line at a time
Ribbon also provides instant access to
break points that call stack and many
other tools that can assist when
analyzing your code.
So upon executing
line 28 we can see that we're now
running C-sharp application.
The breakpoint line 47 allows us to print a
process ID. We can also see that the
repository is not now
so in other words it's not empty
Looking at the project browser, we print
the name of the first package called
example model - followed by getting
started modeling basics and so on.
We can use the execute toolbar to step over H
Line code one at a time.
This helps us to better understand how
the script works.
For example child packages
are published prior to moving
on to the next package in the tree.
We can observe this behavior by taking a
closer look at the modeling basics package.
followed by Line Styles.
All of the code included in the model pattern
can be easily modified to meet your
particular automation needs.
You can use code that's targeted to .net 3.5 or .net 4.5
Some of the benefits of Hybrid Scripting include superior
execution speed, enhance interoperability
and full visual execution analyzer support
If you're an expert in C-sharp or Java
or other .Net languages then you might
consider Hybrid Scripting to get the
most out of Enterprise Architect 13 and automation.
For more information about
Hybrid Scripting or Enterprise Architect 13
Please visit www.sparxsystems.com