Script Editor

Access Astah models via scripting language - ECMAScript(JavaScript) with Script Editor.
You will be able to extract data or modify models easily via script using API. What you can do with this Script Editor is countless!


How to Install

Choose your edition.

How to Install on Astah Pro

If you are using Astah Pro 7.2 or later, the script editor is included already, so skip to "How to use".

  1. Download the Plug-in file by clicking the blue Download button at the top of this page.
  2. Unzip it. There are some sample script files in the "sample_scripts" folder.
    Astah Script Editor
  3. Drag the downloaded .jar file to an open instance of Astah. A pop-up will appear asking you to confirm installation, choose [Yes].
    Astah Script Editor
  4. If the pop-up opens, restart Astah and open any project.
    astah plugin menu
  5. If you see the [Script Editor] option under [Tools], the installation is complete!
  6. Go to "How to Use"

How to Install on Astah SysML

  1. Download the Plug-in file by clicking the blue Download button at the top of this page.
  2. Launch Astah SysML and go to [Help] - [Plugin List].
    astah-sysml plugin menu
  3. Click [Install] button and select the script-x.x.jar file you donwloaded which you can find in the unzipped folder.
    astah-sysml plugin menu
  4. Restart Astah.
    astah-sysml plugin menu
  5. If you see the [Script] option under [Tool], the installation is complete! (This is a screenshot of Astah Professional.)
  6. Go to "How to Use"

How to Install on Astah GSN

  1. Save the downloaded .jar file under Userhome/.astah/gsn/plugins. (You will find the .jar file after unzipping the downloaded package.)
  2. Launch Astah GSN, if you see the [Script] option under [Tool], the installation is complete!

  3. Go to "How to Use"

How to Use

  1. Open a project file you want to use scripts for.
  2. Go to [Tools] - [Script Editor] or [Script] from main menu to open a script editor.
  3. Write script in upper window or go to [Script] - [Open] and select the .js files. (Sample Scripts)
  4. Click the arrow button or go to [Action] - [Run] to run the script.

  5. The result appears in the bottom window.

  6. You can save your scripts from [Script] - [Save as].

Sample Scripts

You can find script samples on Sample Scripts page. Also, if you download the plug-in files from the [Download] button at the top of this page, you will get the following sample .js files.

addSetterGetterAdd Setter/Getter to target Attributes
addStereotypeToSelectedModel.jsAdd stereotype to target models
checkEdition.jsShow the version of currently-used Astah
countClasses.jsShow a number of Classes that are included in the currently-open project
createAndOpenDiagram.jsCreate a new Class diagram
createEREntities.jsCreate new ER entities with specific logical names and physical namess
exportCsv.jsExport model information to CSV format file
printClasses.jsList up all the Class names in the currently-open diagram
printERIndexList up all the Index information of all the ER models
printMindmapTopics.jsList up all the topics in currently-open Mind Map
printPackageAndClassInfo.jsList up all the package and class names
printPresentationProperties.jsList up all the property information of target model element
searchAndEdit.jsSearch a class by keyword and add a specific color and note to it
searchMessagesWithoutOperation.jsList up all the Messages without operations in Sequence diagrams
useJavaGUI.jsOpen a dialog to enable you to use Java GUI

Sample scripts may not work on old version of Astah. If you are using Astah Pro 6.9 or earlier, use the sample scripts in the [sample scripts] - [java7] folder. Also some somple scripts do not work with Astah Community because it does not provide support edit API.

Available predefined variables in the script

projectAccessorprojectAccessor object in Astah API. null means there is no project file in Astah.
astahsame as projectAccessor
astahWindowMain window of Astah
scriptWindowWindow object of the Script Editor

Related Contents

Using other Scripting Language

You can use other scripting language for this Script Editor if you have OSGi bundle and JSR223 jar files.

  1. Download a .jar file of the scripting language you wnt to use. (e.g: groovy-all.jar. jruby-###.jar)
  2. Save the .jar file in the plugins folder in your home directory.
    If you are using Astah Pro, USER_HOME\.astah\professional\plugins
  3. Restart Astah.