The following instructions applies to BeanShell, Groovy, JavaScript, and Jython scripts only.

How to access the arguments and other values from the script body?

To access an argument from the script body, you should refer to the corresponding parameter name.

A script body can access the following values:

How to simplify scripts?

To simplify the script, move complex sub calculations out of the script. Use other operations of the structured expression to specify these sub calculations and then pass the results to the script through parameters.

Let’s say we need a script operation, which counts the number of nested packages. You can use MagicDraw Open API to navigate through the model and find all the nested packages, but it would be complicated.

To simplify the script:

  1. Use the Find operation to list these nested packages.
  2. Use the script operation for nothing else than counting the number of the list items. Pass the result of the Find operation to this script through the PackageList parameter as the following figure shows.