我需要调用一个基于立方体旋转X 的函数(Maya-Python)。为此,我必须以编程方式捕获事件。
我尝试使用while循环,但它卡在循环中,在那段时间什么都做不了。我尝试了theading(python),还是一样。
可以这样做或其他方式吗?如果是,如何?
Windows XP 中的 Maya 2009
一些失败的代码参考:
import maya.cmds as cmds
while (count < 90):
lock = cmds.getAttr('pCube1.rotateX',lock=False)
print lock
count = count + 1
这里是 Python 明智的:
#!/usr/bin/python
import thread
import time
# Define a function for the thread
def cubeRotateX( threadName, delay):
count = 0
while count < 5:
time.sleep(delay)
count += 1
try:
thread.start_new_thread( cubeRotateX, ("Thread-1", 2, ) )
except:
print "Error: unable to start thread"
while 1:
pass