Hi, not sure if this is a bug or intended functionality and wondering if someone could let me know?
I’ve found that the runscript() function will point at both a parent project script and a child project script depending where it is used. I stumbled across this when just messing around with scripting and expression tags in Ignition 8.
Project Setup:
Parent_Project (inheritable)
Child_Project (child to Parent_Project)
Steps:
On Parent_Project
-Created a script called “test”
-test script is:
def myFunc(text=“Hello World!”):
return text
-created an expression tag that has:
runscript(“test.myFunc()”,0)
-this returns “Hello World!” as expected.
-created a blank vision window, with just a new custom property that used an expression binding that is the exact same as the expression tag, and this returns “Hello World!” as expected.
On Child_Project
-created an expression tag the exact same as the Parent_Project above, no issue.
-overriding or creating a new script on Child_Project with the following results in the no change to the expression tag:
def mytest1(text=“test”):
return text
-if the expression tag will no longer work however if it is changed to:
runscript(“test.mytest1()”,0)
-The expression tag only works if it uses the parent project script path, and will only return the value set in the parent project (changing only the “Hello World!” to “Test” on the child but keeping the myFunc name will still return “Hello World!”)
-Created a blank vision window with a custom property using an expression binding:
runscript(“test.myFunc()”,0)
-This will result in an error:
Exception: Error executing expression binding on
Testing Window.Root Container.test
caused by ExpressionException: Error executing script for runScript() expression:test.myFunc()
caused by Traceback (most recent call last):
File “expression:runScript”, line 1, in
AttributeError: ‘com.inductiveautomation.ignition.common.script.Pro’ object has no attribute ‘myFunc’
-if changed to test.test1 instead of test.myFunc it will work and return the value “test”
So, it seems that the expression tags can only reference the parent project and are unable to see the local/child scripts; as well as not registering when a parent script is overridden on the child project.
The component expression bindings don’t seem to have this issue however and will register if a parent script is overridden and can point to scripts created on the child project.