Python - Is it possible to detect when an object moves in the scene?

Python - Is it possible to detect when an object moves in the scene?

Anonymous
Not applicable
1,364 Views
2 Replies
Message 1 of 3

Python - Is it possible to detect when an object moves in the scene?

Anonymous
Not applicable

Basically I am looking if there is some sort of callback function when you move a certain object in the scene. I have looked into official Maya Python docs and I couldn't find anything.

 

If you have any MEL solutions you can post those aswel.

 

Cheers.

0 Likes
Accepted solutions (1)
1,365 Views
2 Replies
Replies (2)
Message 2 of 3

kollig
Advocate
Advocate
Accepted solution

Did you have a look at "scriptJob" (MEL, pymel) and "MNodeMessage" (Python API)?

Both methods allow to register a callback when an attribute changes.

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks!. That worked perfectly.

 

Here is the example if anyone else stumbles upon this problem.

 

def MoveNote():
print "We move"

 

someJob = cmds.scriptJob( ac = ['pCube1.translate', MoveNote], protected=True)

0 Likes