[Vision] Using methods defined in project library on Gateway events

Hi everyone,

I have multiple scheduled Gateway events using functions from a script in the Project Library tree.

In the Gateway scheduled event, I'm importing the script as:

import packageName.scriptName

And below, I use the function directly from the module imported:

my_function(param1, param2, param3)

After the script runs, nothing happens, and I get this message in the schedule monitoring tab under "Gateway Scripts."

Traceback (most recent call last):

  • File "", line 6, in onScheduledEvent*
    NameError: global name 'averagesCalculation' is not defined

The same code works fine when I run it directly in the script console.

How can I access modules created in Project Library from the Gateway? Is this possible?

Don't import library scripts in your project (or anywhere else). Ignition will do that for you. Just call the functions they contain, fully qualified.

The library script must be in the same project as the gateway event, or be in an inherited project.

{ The Vision tag doesn't apply to gateway scope issues, fwiw. }

3 Likes

Yes, that solved the issue. Thank you again!

1 Like