Script functions, attributes and objects - overview
This topic provides information about scripts created for the following extensibility features:
Derived Tag Definitions - created through Tag Definitions. For more information, see Script functions, attributes and objects - derivation scripts for tag definitions.
Diagram Toolbar Buttons - created through Stereotype and Script items. For more information, see the following topics:
Double-Click Behavior - created through Stereotype and Script items. For more information, see Script functions, attributes and objects - double-click scripts.
Menu Commands - created through Stereotype and Script items. For more information, see Script functions, attributes and objects - menu command scripts.
Model Close and Open Behavior - created through Stereotype and Script items. For more information, see Script functions, attributes and objects - model close and open scripts.
On Delete Behavior - created through Stereotype and Script items. For more information, see Script functions, attributes and objects - on delete scripts.
On Drop Behavior - created through Stereotype and Script items. For more information, see the following topics:
Utility Scripts - created through Script items. For more information, see Script functions, attributes and objects - utility scripts.
Note that there are two other types of Script item for variability parameters:
Derivation Script - created through a Variant or Requires Dependency to define derivation script for a variability parameter. For more information, see Script functions, attributes and objects - derivation scripts for variability parameters.
Validation Script - created through a Variant to define validation script for a variability parameter. For more information, see Script functions, attributes and objects - validation scripts for variants and variation points.
You write these scripts using the Microsoft VBScript language. You interact with the Model through the Modeler Automation Interface:
For more information about VBScript, see the VBScript user's guide and reference guide on the Microsoft MSDN website. At the time of writing this topic, the button that follows opens the VBScript section of the Microsoft MSDN website.
For general information about the Modeler Automation Interface, see the Automation Interface section of the Modeler Help.
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.
When you run a script, you always have the Modeler object available to you (except for On Delete and Derived Tag Definition scripts). If you have a Model open in Modeler, you also have the Projects, ActiveProject and Dictionary objects available to you, without needing to create these objects:
The Studio object represents the Modeler editor and can be used to control the user interface. For example, Studio.ClearOutputWindow.
The Projects object is the standard Projects object in the automation interface. The Projects object is the collection of Models that are bookmarked in your Model Explorer.
The ActiveProject object is the standard Project object (for the open Model) in the automation interface. The Project object is the container object for the Dictionary and Diagrams collections, that is, the Model.
The Dictionary object is the standard Dictionary object (for the open Model) in the automation interface. The Dictionary object is a container for all dictionary items in the Model.
* 
The Dictionary object is not available within the OnDrop and OnFinished functions.
The CurrentScript object is the Script object that is currently being invoked, that is, the Script object that owns the Script Text. CurrentScript is similar to the Me keyword in Visual Basic.
A com object referenced by the Profile Prog Id property of a Profile Package is available to your profile scripts, except on delete scripts and derived tag definition scripts.
Note that if the Profile Prog Id contains non-alphanumeric characters, those non-alphanumeric characters are replaced with underscores.
* 
From the Projects object, you can quickly navigate to the active diagram, selected symbols on a diagram, or selected dictionary items. For more information, see the Automation Interface Help.
You can add model object references to scripts, so that you can reference specific items in the model. This is useful when working with Stereotypes in a profile. Model object references are translated into named objects that behave as variables referencing linked objects. When translated to a named object, the name of a named object is derived from the item's id prefixed with 'v_'. Example code:
'InformationExchange is a Model Object Reference.

if not (DroppedItem.item("Stereotype","InformationElement") is nothing) then
set dict=DropResult.item("dictitem")
dict.add "stereotype",InformationExchange
DropResult("View Show Stereotype")="TRUE"
Script.Result=True
else
MsgBox("Only Information Elements can be added")
Script.Result=False
end if
You can declare global variables before the script functions - the script functions can then share values of those variables; however, you cannot share values of variables between the ValidDrop and OnDrop functions in an On Drop script.
To run Visual Basic scripts from Modeler you require a Modeler license and an API Access license.
Was this helpful?