External Libraries Use Ignition 'system'

I'm trying to create a package in the user-lib/pylib directory.

What if i want this external package to have access to the ignition "system" functions. ex. system.tag.readBlocking. How do I include the Ignition system package with the external library?

You don't need to include it. Your code will, when executed by something inside Ignition, automatically have access to the required functions.

If you want to e.g. unittest your library without an Ignition system, consider @thecesrom's incendium package: GitHub - thecesrom/incendium: 📦 Package that extends and wraps Ignition scripting API


thanks for detailed reply! Here's a little more info.

from .test import test

def test():
return system.tag.readBlocking(working path)

when running "import test" from the Ignition script console I get...

Traceback (most recent call last):
File "", line 137, in
File "C:\path", line 2, in test
return system.tag.readBlocking('[System]Gateway/UptimeSeconds')[0].value
NameError: global name 'system' is not defined

Ah. Because of Python's scoping rules, you will have to manually import system in your function.
It looks like the script console might be a little inconsistent with how it loads things, but I got essentially your example to work:

Awesome! Thank you very much, I got it to work. For me the key seemed to be...

You get one import of an external module that includes 'import system'. Otherwise, exit and reopen designer.

No saving changes to a module that includes 'import system' and attempting to reload the external module through ignition script console. I tried importing again, reload, and imp.reload. Though these methods would propagate changes with modules that don't include 'import system'

1 Like