I cannot undo changes made by my script
The scripts provide special functions that allow you to make changes to the model through a transaction.
If you cannot undo the changes made by a script, the script that is making changes to the model is not within a special function.
To resolve this problem, locate the script that is making changes to the model, and move that script to within the special function that is appropriate for the script type. The functions that make changes to a model through a transaction are as follows:
For Diagram Toolbar Scripts—use the OnFinished script function. For more information, click a topic below.
For Double-Click Scripts—use the CommitDoubleClick script function. For more information, click here.
For Menu Command Scripts—use the CommitMenu and AfterMenuCommit script function. For more information, click here.
For On Drop Scripts—use the OnDrop script function. For more information, click a topic below.
For Utility Scripts—use the CommitUtility script function. For more information click here.
Making changes to the model through the preceding functions also minimizes disruption to other users because of item locking. In addition, you can see the changes made by the script without having to refresh your Modeler views.
* 
On Delete and Derivation Script scripts do not have any functions specifically for making changes to the model.