System.perspective.print Help

Can someone please help me understand print in Perspective? From the manual, system.perspective.print - Ignition User Manual 8.1 - Ignition Documentation, it states,

Sends print statements to the Script Console when in the Designer. When in a Session, sends print statements to the Output Console. This function makes scripting diagnostics easier.

I think there is some issue with semantics on this. I refer to the script console under tools, where you can test or practice. From using system.perspective.print, it prints to the output console when in designer, and does nothing when in a session. Is the manual wrong? Is what I described how it works? Does system.perspective.print not work while in session?

Script:

On Designer
image

On Session
image

1 Like

Thanks, didn’t even cross my mind to open the console for the browser.

I still don’t like the terminology they used in the manual.

Well that is the browser console. I don’t know what else they would call it.

1 Like

They didn’t call it the browser console. They referred to the script console, which isn’t correct and then the output console, which is only correct for when in designer.

Yeah, the documentation is just wrong. We’ll get it fixed.

2 Likes

On this subject (dog piling, new issue):

  • Nothing in the Designer Console
  • Error message is the gateway logs
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 18, in valueChanged at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.getSession(AbstractScriptingFunctions.java:104) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:118) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.print(PerspectiveScriptingFunctions.java:512) at jdk.internal.reflect.GeneratedMethodAccessor195.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective session attached to this thread.

at org.python.core.Py.JavaError(Py.java:547)

at org.python.core.Py.JavaError(Py.java:538)

at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:192)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:541)

at org.python.core.PyObject.__call__(PyObject.java:400)

at org.python.pycode._pyx199.valueChanged$1(:34)

at org.python.pycode._pyx199.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:173)

at org.python.core.PyBaseCode.call(PyBaseCode.java:306)

at org.python.core.PyFunction.function___call__(PyFunction.java:474)

at org.python.core.PyFunction.__call__(PyFunction.java:469)

at org.python.core.PyFunction.__call__(PyFunction.java:464)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:831)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:813)

at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$FunctionInvokerImpl.run(TagScriptManagerImpl.java:533)

at com.inductiveautomation.ignition.gateway.tags.scripting.events.AbstractTagScript.invoke(AbstractTagScript.java:34)

at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$Task.invoke(TagScriptManagerImpl.java:482)

at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$TagScriptDispatcher.run(TagScriptManagerImpl.java:445)

at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:539)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective session attached to this thread.

... 25 common frames omitted

Caused by: java.lang.IllegalArgumentException: No perspective session attached to this thread.

at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.getSession(AbstractScriptingFunctions.java:104)

at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:118)

at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47)

at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.print(PerspectiveScriptingFunctions.java:512)

at jdk.internal.reflect.GeneratedMethodAccessor195.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)

... 22 common frames omitted
1 Like

Seems obvious to me:

Caused by: java.lang.IllegalArgumentException: No perspective session attached to this thread.

You can’t use system.perspective outside Perspective events or transforms.

1 Like

@pturmel , thanks, you’ve been doing this for ever so it is obvious.
In my defense, the manual doesn’t say where is can/cannot be used, all it says is " This function is used in Python Scripting.", not about only in events and transforms.

But it does, under Scope. “Perspective Session”.

Every script function has a scope declared in its syntax documentation.

@pturmel Ah, I stand corrected. I should read the fine print better. Thank you Phil