Skip to main content
Version: 8.1

Project Library

Scripts under the Project Library are a project-based resource that allows user created Python scripts to be configured. Objects and functions created in a Project Library script can be called from anywhere in the project. Project Library scripts are accessible from the Project Browser, under the Scripting item.

Additionally, a single project can be designated as the Gateway Scripting Project, meaning that scripts defined in the stated project can be called from the Gateway scope.

Add a Script

To add a a Project Library script, right click the Project Library item and click the New Script option.

Scripts and Packages

There are two main types of resources under the Project Library.

  • Scripts - Each script resource can contain many functions and objects.
  • Packages - Each package effectively acts as a folder, allowing you to better organize each script resource.

Usage Example

For example, let's suppose you added the following script module named myFuncs, whose body is shown below.

def hello():
return "Hi there!"

Once we save our project, we can now call this function from anywhere within the project using the following syntax.

Python - Calling the Project Script

Project Library scripts are not accessible to the other resources until the project is saved.

For example, we could open the Script Console (Tools menu > Script Console), write the following, and execute the script.

Each script resource can contain multiple functions and objects. As you add new function definitions, the list on the right will populate giving you a quick way to navigate through long scripts.

Project Libraries and Execution

Because Python is a dynamic language, any code inside of a project library must be run to build the function and class definitions. This is a common behavior across interpreters. Within Ignition, these project libraries will run under certain conditions. For example, such as when the Script Console in the Designer starts up, if changes are made to third-party libraries inside of the gateway's installation directory, when saving changes to these project libraries, and several other conditions.

When this occurs, code inside of a project library is executed. Meaning classes and functions are defined, and any code that is not contained within either a class or function will execute.

Because of this process, it's generally recommended that all code within a project library is wrapped inside of a function or class definition.

Gateway Scripting Project

Project Library scripts are normally only accessible from the project they were defined in. Thus objects that exist in other scopes, such as Tags that exist in the Gateway scope, are unable to call Project Library scripts. Attempting to do so will result in Gateway log errors stating that "global name 'yourScript' is not defined".

The exception to this rule is the Gateway Scripting Project. This project is specified by the Gateway Scripting Project property, which is set in the Config section of the Gateway Webpage under Gateway Settings. Entering the name of a project under this property allows the Gateway access to Project Library scripts configured in the specified project.

Thus, if the myFuncs library in the prior section was configured in a project named Tester, we would enter Tester in the Gateway Scripting Project field.

Once the name of the project is entered, select Save Changes.

Now, you can start calling any of the global scripting events, such as tag event scripts or runScript calls, from the Tester Project Library.


The Gateway Scripting Project has no impact to Gateway event scripts defined in the Designer (startup, shutdown, update, message handler, etc.) as those are Project Resources and thus only function for the project they run under.


This example demonstrates how to call scripts in your Gateway Scripting Project from a tag.

  1. Set up your Gateway Scripting Project under Config > Gateway Settings:

  2. Open your Gateway Scripting Project and add a library called myFuncs.

  3. Define a new function in this library called thankYou:

    def thankYou(user):
    system.gui.messageBox("Thanks for noticing me, " + user)
  4. Save your Gateway Scripting Project and exit.

  5. Open a new project.

  6. Choose a tag and configure a Tag Event Script on the Alarm Acknowledged event.

  7. You can call any function within the myFuncs library in your Gateway Scripting Project:

    myFuncs.thankYou(user = ackedBy)

    You do not need to specify the name of your Gateway Scripting Project when calling any of its functions.