Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

setSleepCallback in the Python for Maya 2010 MTimerMessage module

setSleepCallback in the Python for Maya 2010 MTimerMessage module

Anonymous
Not applicable
261 Views
0 Replies
Message 1 of 1

setSleepCallback in the Python for Maya 2010 MTimerMessage module

Anonymous
Not applicable
Hiya, I am trying to add a timer callback to Maya 2010; but, I do not
understand how to set a sleep callback for it so that the timer
callback does not monopolize the CPU. In the python api, I thought all
you would have to do is

import sys
import maya.OpenMaya as OpenMaya
import time

def sleepCallback():
time.sleep(0.5)

def timerCallback(elapsedTime, lastTime, clientData):
sys.stdout.write('test\n')
sys.stdout.flush()

OpenMaya.MTimerMessage.setRegisteringCallableScript()
status = OpenMaya.MTimerMessage.setSleepCallback(sleepCallback)
id = OpenMaya.MTimerMessage.addTimerCallback(0.1, timerCallback, "")

But, I get the following error

# Error: TypeError: in method 'MTimerMessage_setSleepCallback',
argument 1 of type 'MTimerMessage::sleepCallbackPtr' #

This is a problem as I do not see sleepCallbackPtr available in
MTimerMessage.
dir(OpenMaya.MTimerMessage)
# Result: #

This is a none issue with the new MTimerMessage::addTimerCallback()
modification in 2011:

MTimerMessage::addTimerCallback() has been modified such that it no longer requires that Maya's idle queue run continuously. As such, the sleepCallback() and setSleepCallback() methods are no longer needed.

But, I need it to run in both 2010 and 2011. What am I not getting
here?

Thanks,
Ryan
0 Likes
262 Views
0 Replies
Replies (0)