Adding New Scripts to the pylib library - All file(s) in a personal created folder

I was testing trying to get this to work, and was successful by following Importing and using 3rd party Python libraries in Ignition and it to worked just fine the first round. I had added a folder inside the pylib folder that had one simple python file. To change the valueSouce based on a radio button selection.

When I added another file, just as simple, to change a tag to enabled or disabled the module can now not be found. I waited for the updating to finish, restarted ignition, and even went back and deleted the new file so it was at when it worked. Even then ignition can no longer find the folder.

Has anyone every delt with this? And is there a better process to do this then just adding a file to the folder with ignition designer still open?

This example is what the python file does:

def valueSourceChange(tagPath, tagType):
"""
The function changes the value source for any tags provided.
• tagPath - the full tag path 
• tagType - What the user chose the new Value source to be
"""
	import system
	# access the valueSource property
	newPath = tagPath + '.valueSource"
	system.tag.writeBlocking(newPath, tagType)
	return system.perspective.print("The value source has been updated")

The folder set up:
• folder name : MyFolder
• PythonFile: Test.py

How I imported it:

from MyFolder import Test

Edit:
this pops up on the console but never says finished updating. Can not remember if it did so the first time. Is it supposed to?

13:53:28.054 [ClientProgressManager-1] INFO PyLib_ChangeListener - Updating 'pylib' contents from Gateway.

I would not add files to the pyLib with Ignition specific things in them. That isn't really the intention there. It is rather intended to be used for Python Libraries, like for instance xlrd or urllib2 (just random examples).

For scripts that are specific to Ignition projects you should be using the Project Library, accessible from the designer.

https://docs.inductiveautomation.com/display/DOC81/Project+Library

2 Likes

Ah ok Gotcha. This was just for me to test it out, and was curious why it worked the first time but then just stopped working.

Edit:

I am not 100% sure why I can not add these mini functions to the library itself. That said, this work just fine in the project scripting part using perspective.