Destroy Objects in a Simulation

Having created or generated Objects in your simulation model, you can define Actions to destroy those objects at any point during the process. All simulation objects are destroyed automatically when the simulation completes.

You have two options for destroying the Objects in your simulation model:

Dynamically destroy the Objects through a DestroyObject Action element

Dynamically destroy the Objects using Javascript in an Action element

The result of the deletion can be observed in the change of local variables, on the Local window.

Destroy an Object through a DestroyObject Action

Step

Action

See also

1

On your Activity diagram, drag an 'Action' icon from the Diagram Toolbox, and select the 'Other | DestroyObject' context menu option to define it as a DestroyObject Action element.

Perform a Simulation on the diagram. The process passes the Object name or value into the Input Action Pin as a parameter. When the DestroyObject Action is executed, it deletes the Object having that name or value from the model.

In the example, the instance of Class1 is specifically destroyed before Action4 is processed, but the results of Action2 are unaffected.

Destroy an Object using Javascript

In the 'Properties' dialog of the Action element, in the 'Effect' field on the 'Effect' page, type either:

sim.DestroyObject ("objectname")

or

delete sim.objectFullName

For example:

Notes

In either case, you can also destroy a global object (one that is created outside the process flow) by identifying the Object to the Action performing the destruction; in the case of the DestroyObject Action, by passing the Object name from a Port on the Object to the Input Pin on the Action through an Object Flow connector