Manipulating run-time objects with scripts lets you dynamically control simulation environment, structural elements, and behavioral workflows. You can modify structural and global variables, invoke behaviors and operations. You can also create and send signals, and retrieve key runtime data like token values, simulation time, and callers of the scripts. Additionally, you can evaluate expressions and check behaviors to gain information about the simulation.
Action scripts can be used where the scripts are evaluated during simulation, for example in the Opaque Behaviors, Actions, Guards, or directly in the simulation Console pane). You can use the following types of action scripts to manipulate runtime objects:
ALH (Action Language Helper) scripts. Example: ALH.getValue(object, "property")
It is easy to access elements that are deeper in the hierarchy tree, but accessing parent elements is more complicated. Therefore, it is important to plan where executing a particular script would be the most efficient. |
Scripts are context sensitive, whenever you execute a script, you must specify its context (object). Mostly, it is the current simulation context (marked as "self" in a script). However, it can also be an input pin (pin name) or an object created in a script itself (see Creating a runtime object (Copy)). When evaluating from Simulation console, the context depends on the selected element in the variables pane. For example:
To get the Diameter Value Property when the script is executed in the Car Block, the script should be self.get("tyre.wheel.Diameter").
To get the Diameter Value Property when the script is executed after selecting the wheel, the script should be Diameter.
The first level properties can be directly accessed using their name. |
To learn more, refer to the following topics:
Additional resources