Sunday, January 2, 2011

Useful Commands

whatIs
whatIs script;   //mel only
whatIs statusLineUpdateInputField;   
// Result: Mel procedure found in: C:/Program Files/Autodesk/Maya2009/scripts/startup/statusLine.mel // 

When you need to emulate a command from Maya and the script editor only gives feedback when Echo All Commands is checked.  Maya most likely echoed a built in mel procedure that runs multiple mel commands in the background. Just open the file, find the procedure, and begin sifting through Maya's internals. 

evalDeffered
cmds.evalDeferred("cmds.refresh(force=1)", lowestPriority=1) 
cmds.evalDeferred(lambda : localCommand, lowestPriority=1) 

Often a command will return a result before the intended process is complete.  This is often a result of commands firing idle scriptJobs.  The problem is your code continues while Maya is trying to play catch up.  evalDeferred will wait until Maya is completely idle (no more queued scriptJobs) before continuing.