Scripting in Vissim

Note: Vissim demo versions not do not support the execution of scripts via the COM interface.

Note: Microsoft replaces VBS  VBScript deprecation: Timelines and next steps

Purpose of the Scripting API using the COM interface add-on module

Vissim has a scripting API that uses the COM interface add-on module ( Wikipedia: Component Object Model, (Overview of add-on modules). You can use it for the following purposes:

  • Preparation and postprocessing of data
  • Efficiently controlling the sequence in order to examine scenarios
  • Including control algorithms which you have defined
  • Access to all network object attributes
Ways to use the COM interface for interaction with Vissim

You can use scripts externally and internally. The two options differ in the following technical aspects:

  • ►  On the Actions menu, click > Event-Based Scripts.

or

  • ►  On the Actions menu, click > Run Script File.

Only Python scripts and VBS scripts are supported. Internal scripts are run as part of the current Vissim process. As a result, the speed at which internal scripts are executed is generally higher than that of external scripts. There are restrictions (Requirements and notes for internal scripts).

Video: Scripting in PTV Vissim using the COM interface

Note: Full-screen playback of the video is only available in Google Chrome and Microsoft Edge. To view in other browsers, click on the title of the video in the preview.

Introduction to COM Programming and COM API Reference

An introduction to COM programming, information on the available functions and related commands can be found in English in the Vissim - COM API reference that can be displayed in the browser:

  • ►  On the Help menu, click > COM Help.

You can find examples in the following default directory:

  • ..\Users\Public\Public Documents\PTV Vision\PTV Vissim 2026\Examples Training\COM\

Requirements and notes for external scripts

In order to start Vissim and interact with Vissim, you can use any programming language that supports COM. You can find information and examples in the following default directory:

..\Users\Public\Public Documents\PTV Vision\ PTV Vissim 2026\Examples Training\COM\Basic Commands.

Python versions

Use the Python version of your choice, from Python 3.9 64 bit and higher.

Vissim uses the Python package pywin32 for the examples provided with Vissim in order to support COM in Python.

Requirements and notes for internal scripts

Vissim only supports Python and VBS scripts as internal scripts.

You can find examples in the following directory:

..\Examples Training\COM\Drop-off Zone.

The global variable Vissim is available in the scripts and is a Vissim interface, which refers to the Vissim instance that started the script. You can find further information in the Vissim COM API reference.

The internal script is executed Vissim as part of the Vissim-process. Therefore, you do not need to start Vissim manually. If necessary, you can start additional instances of Vissim. To do this, the necessary licenses are required. For other instances started by Vissim, Vissim treats the script as an external script.

Additionally, you can use the CurrentScript variable to create a reference to the current script, for example, to access user-defined attributes there.

Debugging internal scripts is more difficult than debugging external scripts asVissim starts the scripts itself; you cannot start an internal script directly in a debugger.

Depending on the use case, it may be useful to write the script as an external script first and then convert it to an ternal script.

You can also use the IVissim.Log function to save debug messages to the Messages list of Vissim.

Python as part of the Vissim installation

By default, Python is installed in the following Python directory of Vissim:

..\Exe\Python

This installation is used by any Python script that is run within Vissim Therefore, you do not need to manually install Python to run internal scripts. .Vissim uses the Python package pywin32 to support COM in Python.

Note: Do not modify Python installed using Vissim; for example, do not install additional packages to make them available in internal scripts. Modifications can cause problems, for example:

  • Undesirable behavior of Vissim
  • Incorrect installation of updates
  • Incorrect installation of new Vissim versions
  • Incomplete uninstallation of Vissim
Additional packages in internal scripts

1.  In Windows Explorer, display the directory where the Python version was installed usingVissim.

By default, the ..\Exe\Python directory is used.

2.  Right-click the python.exe file and on the shortcut menu, select Properties > Details.

3.  Find out which product version you are running.

Python 3.13 is installed for Vissim 2026, for example.

4.  Go to https://www.python.org/ and download the same main version, for example Python 3.13.* in 64 bit for Vissim 2026.

5.  Install this Python version outside the Vissim installation directory on your computer.

6.  Create a dedicated virtual environment venv for this installation in a directory outside of the Vissim installation directory and outside the Python installation directory, for example in your Home directory:

py.exe -3.13 -m venv "C:\Users\<name>\python313_venv_vissim"

7.  Install the desired packages in this venv, for example pandas:

C:\Users\<name>\python313_venv_vissim\Scripts\pip.exe install pandas

8.  In your internal script, add the path to the venv directory to the sys.path list at the beginning of the script, for example:

import sys

sys.path.append(r"C:\Users\<name>\python313_venv_vissim\Lib\site-packages")

Notes:

  • This path allows Python to find the additional packages that you will then import. Only import packages after this step; the path to the venv directory must be entered before importing.
  • The sys.path should not refer to the separate Python installation. Instead, create a dedicated venv that the sys.path refers to. Otherwise, your scripts may attempt to load incompatible base libraries that are included in both the Vissim installation directory and your own Python installation.
  • Do not install pywin32 in your venv, as it is already available in the Vissim installation directory by default. The installation may cause incompatibilities.

Accessing attributes via the COM interface

Using the AttValue method, you have read access to all network object attributes. Write access is not available for all attributes. In the COM Help, the Editable row of each attribute specifies a True or False value, indicating whether or not the attribute can be write-accessed.