Printing to console from custom node while playback or timeline scrubbing.

109 views
Skip to first unread message

Simone Tartaglia

unread,
Nov 8, 2017, 5:08:22 AM11/8/17
to Python Programming for Autodesk Maya
Hi guys, is the first time I'm posting in this group, but I've been a long time follower.

Scenario:
I'm scripting a custom plugin node that checks the value of an input. 
If the input value is major than a "limit value" attribute in the custom node, it then prints a warning to the console.
In order to print to the console from inside the compute() method I'm using a standard print() function.

Problem:
The node is working correctly, but during playback and timeline scrubbing the warning are printed all at the same time, at the end "on release" of the mouse click.
I'd like the node to print the warning messages every time it evaluates rather than at the end.
Scenario that happens only on timeline scrubbing and playback.

I've been searching around and the 2 possible solution I've found so far are:
1 - scriptjob on "timeChanged"
2 - expression node, to print every frame

Both the solutions seems to me patchy workarounds rather than solid answers.
If you could point me in the right direction it would be much appreciated!!

all the best,

Simo.

Michael Boon

unread,
Nov 9, 2017, 9:13:40 PM11/9/17
to Python Programming for Autodesk Maya
I've noticed that print can be delayed until Maya is idle. You might want to try other methods of printing.
If you have a logger object, logger.info is often more responsive than print.
Or maybe you could use something like MEL's headsUpMessage or a GUI element like a messageLine?

Balazs Pataki

unread,
Nov 10, 2017, 6:05:05 AM11/10/17
to Python Programming for Autodesk Maya
This is due to the evaluation manager. If you switch to DG instead of Parallel, you will see that it will work.
Ok, so how should we go around not limiting ourselves to DG evaluation only?
The problem is the printing into the script editor, instead, you could log into the Output Window with sys.__stdout__:
import sys
sys
.__stdout__.write('hello\n')


logger.info would suffer from the same problem since it would out pipe into the Script Editor, but logging to a file would work, but it's the interactive thing you probably wanted.

Simone Tartaglia

unread,
Nov 10, 2017, 6:51:06 AM11/10/17
to Python Programming for Autodesk Maya
Thanks Michael and Balazs,
I liked the logger option as it's faster and better than print(), but unfortunately as Balazs says, it suffers of the same problem.

Balazs, I've tried to set to DG and Serial and they also suffer of the same problem, the output to console feedbacks only after mouse release.

Using the stdout function, as suggested, works, but with the drawback that only works in the output window and not in the console output.
That means having the output windows in "always on top", it's definitely a better solution than not having a real time feedback, but not the solution I was looking for.



Balazs Pataki

unread,
Nov 10, 2017, 10:42:20 AM11/10/17
to Python Programming for Autodesk Maya
No need for always on top, 2-3 monitors or just scale the windows :P

If you can provide an example maybe we could figure something out.

Simone Tartaglia

unread,
Nov 14, 2017, 7:19:55 AM11/14/17
to Python Programming for Autodesk Maya
Hi guys,
here there is a very simple plugin to show how I've set up the node.
If you can give it a go and let me know if there's a better solution in order to print to console in a more responsive way, that would be much appreciated!
The maya scene is in maya ASCII 2018, if  you can't read it, it's basically just a locator with an animation on tX, that goes into the checkValue node inputValue, and the checkValue node outputValue that goes into another locator tX.

all the best,

valueCheck.py
checKValueTest.ma
Reply all
Reply to author
Forward
0 new messages