Maya 2025 Swap Axis Orientation Loop (World,Object,Component)

Hi i did this long time ago i cant remember whats the good combination of modes
Right now its all mess up, but the Script loops between World,Object,Component Axis Orientation.
The problem is the headsUpMessage doesnt match with the Selected One.
But It works!

##--------------------------------------------------------------------------
##TRANSLATE ROTATE SCALE
##0 - Object Space 0 - Object Space (default) 0 - Object Space
##1 - Local Space 1 - World Space 1 - Local Space
##2 - World Space (default) 2 - Gimbal Mode 2 - World Space (default)
##3 - Move Along Vertex Normal 3 - Custom Axis Orientation 3 - Scale Along Vertex Normal
##4 - Move Along Rotation Axis 4 - Scale Along Rotation Axis
##5 - Move Along Live Object Axis 5 - Scale Along Live Object Axis
##6 - Custom Axis Orientation 6 - Custom Axis Orientation
##10 - Component Space 10 - Component Space 10 - Component Space
##--------------------------------------------------------------------------

import maya.cmds as cmds

def SwapAxis():

# Get the Object Selected



selected = cmds.ls(selection=True)

if not selected:

    cmds.headsUpMessage("Theres not Object Selected", verticalOffset=120)
    return


obj = selected[0]

ctx = cmds.currentCtx()
 
if ctx == 'moveSuperContext':
   
    tool = 'Move'
    mode = cmds.manipMoveContext(tool, q=1, m=1)
    if mode == 2:
        cmds.manipMoveContext(tool, e=1, m=0)
        cmds.headsUpMessage('World', verticalOffset=120)
    elif mode == 0:
        cmds.manipMoveContext(tool, e=1, m=10)
        cmds.headsUpMessage('Object', verticalOffset=120)
    elif mode == 10:
        cmds.manipMoveContext(tool, e=1, m=2)
        cmds.headsUpMessage('Component', verticalOffset=120)
        
if ctx == 'RotateSuperContext':
    
    tool = 'Rotate'
    mode = cmds.manipRotateContext(tool, q=1, m=1)
    
    if mode == 0:
        cmds.manipRotateContext(tool, e=1, m=10)
        cmds.headsUpMessage('Object', verticalOffset=120)
    else:
        cmds.manipRotateContext(tool, e=1, m=0)
        cmds.headsUpMessage('World', verticalOffset=120)
 
if ctx == 'scaleSuperContext':
    
    tool = 'Scale'
    mode = cmds.manipScaleContext(tool, q=1, m=1)
    
    if mode == 2:
        cmds.manipScaleContext(tool, e=1, m=0)
        cmds.headsUpMessage('World', verticalOffset=120)
    elif mode == 0:
        cmds.manipScaleContext(tool, e=1, m=10)
        cmds.headsUpMessage('Object', verticalOffset=120)
    elif mode == 10:
        cmds.manipScaleContext(tool, e=1, m=2)
        cmds.headsUpMessage('Component', verticalOffset=120)

Save this as SwapAxis.py
In the hotkey editor, create a new RuntimeCommand as Python
Paste this to call:

import importlib
import SwapAxis
importlib.reload(SwapAxis)
SwapAxis.SwapAxis()

I choose the F3 as hotkey
save Runtime, save and close hotkey editor cheers
ps: how can i put all the Script in the window box.

1 Like