Script Editor

By installing this Plug-in, you can add a script editor where you can access Astah models via scripting language - ECMAScript(JavaScript).
This plug-in is pre-installed if you are using Astah Professional version 7.2 or later.

Versions


How to Install

Choose your edition.
      


How to Install on Astah Professional and Astah Community version 7.1 or earlier

If you are using Astah Professional 7.2 or later, this plug-in is already installed, 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 the files. 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
    The [Plugin] menu exists in Astah Professional version 7.2 or later. If you are using other versions, read FAQ.
  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 and go to [Help] - [Plugin List].
    astah-sysml plugin menu
  3. Click [Install] button and select the .jar file you donwloaded. (You can find the .jar file after unzipping the downloaded package.)
    astah-sysml plugin menu
  4. Restart Astah and open any project.
    astah-sysml plugin menu
  5. If you see the [Script Editor] option under [Tools], 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] from main menu ([Tools] - [Script] if you are using older version.) 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 some samples on Sample Scripts page.
If you download the plug-in files from the [Download] button at the top of this page, the following sample .js files are stored.

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 specific version of Astah. If you are using Astah Professional or Community 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.





Overview

Available predefined variables in this 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

use Astah API in script editor