The Enterprise Architect VBScript Library is an open source library of VBScripts written to be used in Enterprise Architect.
This article explains how to download, import and use the library in Enterprise Architect.
The Enterprise Architect VBScript Library contains some scripts to load and save scripts from/to your file system, but before we can use those we have to import an initial set of scripts to get started.
After downloading the file select menu option Project|Data Management|Import Reference Data and choose the downloaded file. Make sure to select Automation scriptsand click Import.
This will import the minimum set of scripts required to load other scripts from the file system
Download library from GitHub
From the Enterprise Architect VBScript Library project page on GitHub you can either choose to download the library as a zip file, or download the repository in GitHub desktop.
Load library into Enterprise Architect
One of the scripts in the initial set is the scriptLoadScripts in the group Script Management. If you execute this script you can choose the library folder from the library downloaded from GitHub.
The script will then scan the entire folder tree and it will load any .vbs file it can find.
For starters it might be interesting to only load the Frameworks scripts as they have the most chance of being useful to anyone.
If the LoadScripts script finds a script that already exists in Enterprise Architect it will ask to overwrite the existing scripts.
In order to know in which group the script belongs it will look for a the group indicator in the script.
This will tell the script that this script should go in the group Script Management. If the script indicator is absent it will assume the group name is the name of the folder where it was found.
After loading the scripts into EA make sure to press the refresh button to make the scripts appear in the GUI.
Saving all your scripts
In the script management group there also a script to save all your scripts to the file system.
In order to control where the script should go you can add the path indicator to the script like this
The path indicator will control where to place the script relative to the chosen folder.
If the path indicator is absent the name of the script group will be used as name of the folder.
Being able to save and load the scripts from/to the file system now allows us to use version control on these scripts.
The library structure
The library is structured in two main parts.
Contains an assortment of various scripts written for various projects.
Contains the framework scripts that are meant to be used by other scripts
Contains helper scripts and classes such as TextFile, SQL, XML etc..
Contains the wrapper classes for EA elements such as TaggedValue, Script, ScriptGroup
The scripts in the projects folder can be used for inspiration, but it is mainly the scripts in the Framework part that are useful when writing scripts.
Using the library
The first thing you need to do when you want to use any of the framework classes is to include the framework in your script
This will include the “Include” script that takes care of including all the other scripts of the framework, including those of the Utils folder.
Then you can use the classes defined in the library. For eaxample, if you want to have the user select a directory you can use following code
The classes in the library contain both properties as operations. You can use the properties as you would expect from “real” classes.