1

キューブの回転 X に基づいて関数 ( Maya-Python ) を呼び出す必要があります。そのためには、プログラムでイベントをキャプチャする必要があります。

while ループを使ってみたのですが、ループの中でスタックしてしまい、その間何もできません。私はテディング(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
4

1 に答える 1

1

It sounds like a scriptJob may be what you're after. Here's a simple example below. However, in this example the callback will only be called when you release the mouse from rotating.

import maya.cmds

def myRotateCallback():
    print 'do something'

maya.cmds.scriptJob( attributeChange=['pCube1.rotateX', myRotateCallback] )

If you want to receive continuous callbacks while rotating the cube, you can do that at the maya API level with MNodeMessage::addNodeDirtyPlugCallback.

于 2010-04-21T17:34:30.273 に答える