Here’s another quick little hotkey. I wanted something to toggle the display of a joints local rotation axis… now I know there is a simple one liner that is already sitting in the hotkey editor, but, if your selection contains some objects with local rotation axis on and some with it off, it’s unlikely the desired effect is to switch the offs to on and the ons to off (are you following me?). So this may be overkill, but here it is:
'''Hotkey: Toggle Local Axes Together'''
import maya.cmds as cmds
axes_on, axes_off = [], []
selection = cmds.ls(selection=True)
for selected in selection:
if cmds.toggle(selected, query=True, localAxis=True):
axes_on.append(selected)
else:
axes_off.append(selected)
if not axes_on:
cmds.toggle(localAxis=True, state=True)
elif not axes_off:
cmds.toggle(localAxis=True, state=False)
else: cmds.toggle(localAxis=True, state=False)