Where Is Scripting Used?
Python is used in many places in Ignition. Each location has its own events that trigger your scripts to run, and add functionality to your projects in different ways. The most apparent place is in event handlers on components and other objects in Vision Clients and Perspective Sessions.
Script Scope
One important thing to keep in mind before scripting in Ignition, is to understand the concept of scope.
Within Ignition, there are different scopes:
- Gateway Scope - The script runs on the gateway. Scripts running in this scope cannot interact with components in the other two scopes.
- Perspective Session Scope - The script runs as a part of a Perspective Session. Note that scripts in Perspective execute on the gateway, not in the browser, but this scope is still distinct from the Gateway Scope.
- the Vision Client Scope - The script runs inside of an instance of a Vision Client.
Where a script was written determines which scope it executes in. For example, Tags are in the Gateway Scope, so Tag Event Scripts execute in the Gateway Scope.
This means that the script will not be able to access any client level resources such as windows or components that you may have open in the Client. Additionally, some of the system functions like system.gui.errorBox only work in the "Client Scope," so you will not be able to use them in the script on the Tag.
System Functions, Hints, and Autocomplete
Ignition comes with a group of system functions, which are built-in functions that interact with Ignition features.
Code Block |
---|
language | py |
---|
title | Python - Simple Script Using a System Function |
---|
|
value = system.tag.readBlocking(["tagPath"]).value |
A complete list of these functions (with their definitions) is available from the autocomplete popup. Wherever you can add a script, type system. and then press Ctrl+Space to get a list of all the functions available. If you keep typing, the list will be automatically narrowed down for you. Additionally, the System Functions page in the appendix contains complete documentation for the built-in system functions.
Note_friendly |
---|
The autocomplete popup always shows all system functions scoped to the current script. If a system function does not appear in the list, that means the function is not available in the current scope, or has been deprecated. |

Starting in 8.1.18, the autocomplete popup is enabled by default and will appear after typing "."
The new editor also offers parameter completion assistance; if you auto-complete a method with multiple required parameters, you’ll automatically enter a “parameter assistance” mode, where you can tab through the parameters and enter them one at a time:

To disable these features, right-click anywhere within the Script Editor window and deselect Automatic Activation and/or Parameter Assistance.

Autocomplete hints are now also displayed for code other than Ignition's system functions. If Ignition detects a function or project script, a popup will automatically appear, from which you can select which function or project script you are trying to reference. You can also bring up this popup by pressing "ctrl-space".

Autocomplete hints will extract method parameters, return information, and limited type awareness for project script functions and class docstrings written in Google Python Style Guide's docstring format. An example of the expected format is as follows:
Code Block |
---|
language | py |
---|
title | Code Snippet |
---|
|
def setMode(mode):
"""Changes the mode of the running system
Args:
mode: An integer representing the mode to switch to.
Returns:
A boolean that indicates if the attempt at switching to the given mode was successful.
Raises:
Error: If communications are down, an exception will be thrown.
"""
# Function code goes here |
The code above will display the description, parameter, and return information when autocomplete hints render the docstring:
Image Added
Editor_notes |
---|
Replace the image above with this one upon 8.1.33 release Image Modified |
Script Hint Scope
You can choose the scope of your scripting hints and suggestions come from by selecting the dropdown menu in your Project Library's scripts:

The table below lists possible values you can choose from in the dropdown menu:
Value | Description |
---|
None | The project library will not use the Designer nor the Gateway to populate scripting hints. |
Designer | The project library will use the Designer scope to populate scripting hints. |
Gateway | The project library will use the Gateway scope to populate scripting hints. |
All | The project library will use both the Designer and Gateway scope to populate scripting hints. |