Wednesday, 13 April 2022

Useful Scripts: Turn off ALL local rotation handles

Exposing local rotation axis allows you to see the position and orientation of a node that doesn't have a shape node and so isn't visible in the viewport.

But you can't select an object by its rotation axis, so if you don't remember which object it was, now you have no idea where that rotation handle is coming from!
You might reason that if you know what object is in that position, then you know which node to go after. Ah but in rigging, such as in character rigs, it's very common to have a dozen nodes occupying to same position and even the same orientation.
And then every time to toggle a handle and it doesn't go away you know you've instead just turned that object's handle on, so now there are multiply objects with their handles visible, and you don't remember which ones...

Oh! And you can't toggle the rotation handles from the channel box, and if you use the attribute editor, you can't effect multiple objects in a selection at once, so no help there.

So the following is a nice simple script that just turns off all the local rotation axes in the entire scene (assuming they aren't locked)
Very handy when you just aren't in mood. No need to select anything, just run it and it will take care of everything:


import maya.cmds as cmds


# The attribute of interest

axisAttr = 'displayLocalAxis'


# Get all DAG nodes in scene

allObjs = cmds.ls(dagObjects=True)


# Find any display axis attributes that are on and turn them off

for obj in allObjs:

    if cmds.attributeQuery(axisAttr, node=obj, exists=True) == True:

        if cmds.getAttr('{}.{}'.format(obj, axisAttr)) == True:

            cmds.setAttr('{}.{}'.format(obj, axisAttr), False)

No comments:

Post a Comment