Selecting and executing a script file

In Vissim you can select and execute external script files. The following scripting languages are supported:

Not supported:

  • The wrapper wxPython
  • The Python distribution anaconda

Tip: You may also manage scripts, which are executed during a simulation at a chosen time, to the network file (Using event based script files).

The global variable Vissim can be used without initialization in the script and always refers to the running Vissim, from which the script has been started. Additionally, you can use the variable CurrentScript to create a reference to the current script, e.g. in order to access user-defined attributes there.

You need not create a Vissim object, using CreateObject, as Vissim has already been started. If additional instances of Vissim are required in the script, you can use CreateObject.

Scripts may include any command of the scripting language, e.g. loop, branch, entry, and output commands.

Scripts must not contain any global declarations.

Executing script files

1.  On the Actions menu, click > Run Script File.

A window opens.

2.  Select the directory to which the script file has been saved.

3.  Select the desired script file.

4.  Click the Open button.

The script file is executed in Vissim.

Examples of script files

The following directory contains a Vissim network that uses script files: ..\Examples Training\COM\Drop-off Zone. This example is available for Visual Basic Script (VBS) and Python.

The following scripts are used to halve the volume of the first time interval for each input.

Example 1 of a *.vbs script file

For each flow in all_flows
For i = 1 To all_flows.Count
flow.AttValue("Volume(1)") = 0.5 * flow.AttValue("Volume(1)")
Next

Example 2 of a *.vbs script file

all_flows = Vissim.Net.VehicleInputs.GetAll
For i = 0 To UBound (all_flows)
all_flows(i).AttValue("Volume(1)") = 0.5 * all_flows(i).AttValue("Volume(1)")
Next

Superordinate topic:

Using the COM Interface