The following instructions applies to BeanShell, Groovy, JavaScript, and Jython scripts only. |
To access an argument from the script body, you should refer to the corresponding parameter name.
A script body can access the following values:
Values passed to the structured expression, inside of which the script operation is defined.
If you have an opaque behavior with a couple of parameters, you can refer to them from a script operation, which is inside of the structured expression - the body of this opaque behavior. |
If you have a structured expression specifying a derived property, validation rule, relation criterion, etc., use THIS to refer to the Contextual element. |
Arguments passed to a nested operation as parameters, if the script operation is defined inside of that nested operation.
Globally defined values:
project (current project)
application
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:
|