Script functions, attributes and objects - on delete scripts
In addition to the standard Modeler automation interface functions, objects and attributes, there are special functions, objects and attributes you can use in the scripts of Stereotypes and Script items. For general information about extensibility scripts, including information about the Studio, Projects, ActiveProject and Dictionary objects that are available in most script functions, see Script functions, attributes and objects - overview.
Note that you cannot use the Studio object in an On Delete script.
To write scripts you require a good working knowledge of the VBScript language, the Modeler Meta Model and the Modeler Automation Interface.
* 
If you run a script that has errors, those errors can cause Modeler to crash and corrupt Modeler model data.
An On Delete Script can include the following object:
Example code:
'This OnDelete script for classes looks to see if there are
'structure diagrams that feature the class in question as the
'class the script tidies up by deleting these diagrams too.
'only class. Based on the assumption that such diagrams only
'feature to document the internal structure of the deleted

Script.Result=False 'Don't commit the transaction
Set oSymbols=CurrentObject.Items("STRD Class")
For Each oSymbol In oSymbols
Set oDiagram=oSymbol.Item("Diagram")
If CLng(oDiagram.ItemCount("STRD Class")) = 1 Then
Set oDiagrams=oDiagram.Item("Diagrams")
oDiagrams.Remove "Structure Diagram",oDiagram
End If
Next
Script.Result=True 'Do commit the transaction
CurrentObject object - is the item or diagram that is going to be deleted.
Script.Result Script attribute - specifies whether the deletion is allowed. If Result is set to TRUE, the deletion is allowed, if Result is set to FALSE, the deletion is abandoned.
Note that because of propagation, associated items that are mandatory may not be present when running an On Delete script. For example, an Association must have a source item and a target item. If the Association has an on drop script that deletes its source and target items, there are no problems when a user deletes the Association; however, if a user deletes the Association's source item, that deletion propagates to the Association - when the Association's on delete script is run, the Association does not have a source item because it has already been deleted.
Was this helpful?