Ever came across the situation of needing a space to work one way and in the next moment exactly the opposite way? Was your conclusion a 2nd control to avoid cycles in Maya? (Scroll to short answer) Long answer Imagine the situation of having a weapon in the rig for instance – some animators might just want the hands to follow the rifle, makes sense, right? But some animations using the same rig are made for a pistol instead – it’s understandable that your animators might want to animate the right arm instead of the weapon control. You come up with a smart way of making the left hand having a right hand space and a world space to accommodate for this. Then out of nowhere the direction says that you’ll need to support a left handed weapon animation. It gets more and more complicated and it can be very […]
Monthly Archives: December 2017
Hi guys, In a few days I am going to post my way of doing space switching perfectly avoiding cycles. I will show how to create spaces where you can for instance have the left hand follow the right hand and the other way around – in one rig and with logic node networks only. Check back this week for an in depth tutorial how to do that. You’ll love it and it’s not even difficult. Please follow and like:
Whenever you want something to happen when your selection in Maya changes, the first thing that comes into your mind might be Maya ScriptJobs. However I find them very slow and not reliable, especially since they are wrapped in mel. Better use a callback from OpenMaya’s messaging system. This is how you do it: You will have to create a function that is called every time the selection changes. Make it run fast and with lots of error checking to avoid making your tool too slow. In your function, get the selection and evaluate what you want to do with it. The function could look something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from maya import OpenMaya #function to execute when selection changes def maya_selection_changed(*args, **kwargs): try: sel = OpenMaya.MSelectionList() OpenMaya.MGlobal.getActiveSelectionList(sel) selection_iter = OpenMaya.MItSelectionList(sel) obj = OpenMaya.MObject() # Loop though iterator objects while not selection_iter.isDone(): # Now we can do anything with each of selected objects. # In this example lets just print path to iterating objects. selection_iter.getDependNode(obj) dagPath = OpenMaya.MDagPath.getAPathTo(obj) print dir(dagPath) print dagPath.fullPathName() print dagPath.partialPathName() #print dir(dagPath) selection_iter.next() except RuntimeError, err: print err |
Don’t worry, you don’t have to use maya API but you can use pymel or even maya.cmds instead. In my example I just print the names of the selected nodes however I would avoid any prints as they are slowing down […]