Search

User Manual

Getting Started


Modules and Platform


Appendix


Tutorials & Helpful Tricks


Glossary


Strategic Partner Links

Sepasoft - MES Modules
Cirrus Link - MQTT Modules

Resources

Inductive University
Ignition Demo Project
Knowledge Base Articles
Forum
IA Support
SDK Documentation
SDK Examples

All Manual Versions

Ignition 8
Ignition 7.9
Ignition 7.8

Deprecated Pages

Skip to end of metadata
Go to start of metadata


Overview

Scripts under the Project Library (called "Project Scripts") are a project-based resource that allows user created Python scripts to be configured. Objects and functions created in a project script can be called from anywhere in the project. Project 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. 


On this page ...


How to Use Script Modules

To add a a project script, simply 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.

Python
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
myFuncs.hello()


Don't Forget to Save

Project 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. Note that as you add new function definitions, the list on the right will populate, allowing you a quick way to navigate through long scripts. 



Accessing Project Scripts from the Gateway

Project scripts are normally only accessible from the project they were defined in. Thus objects that exist in other scopes, such as tags which exist in the gateway scope, are unable to call project 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 Script Project property, under the Gateway web pages > Config > Gateway Settings

Entering in the name of a project under this property allows the gateway access to project scripts configured in the specified project. 


Thus, if the myFuncs library in the prior section was configured in a project named "Tester"


We could use that name in the Gateway Scripting Project.

After we save, tags and other gateway scoped resources can then start calling any of the scripts from our project library in the "Tester" project. 



  • No labels