Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Shortcut to change XYZ Axis while manipulating an object

Anonymous

Shortcut to change XYZ Axis while manipulating an object

Anonymous
Not applicable

HI!

is there any shortcut in Maya to change any XYZ Axis without having to click to change axis for manipulation?

 

Like i want to change from X axis to Y/Z while Moving/Scaling/Rotation and i dont have to click on each other axis to manipulate the object in that axis. 

THANK YOU.

 

Reply
Accepted solutions (1)
3,241 Views
6 Replies
  • maya
Replies (6)

GiacCol
Contributor
Contributor

Hi there,

If you take a look at Maya's documentation (in the command section) you'll find what you are looking for. To change the active axis for the manipulators you need to invoke these commands:

    1. Move - manipMoveContext

    2. Rotate - manipRotateContext

    3. Scale - manipScaleContext

 

So, what you need to do first is to "edit" the state of the manipulator, which you can do so using the flag -e (edit). Then you need to specify that you want to change the current axis using -cah (currentActiveHandle). You can then specify the axis by typing 0 (x) 1 (y) 2 (z) 3 (aligned to view) and end the line by specifying the manipulator context you whish to affect. Like so:

    manipMoveContext -e -cah 0 Move;

This sets the Move manipulator to operate exclusively on the X axis. By following the same example you can create custom shortcuts for each axis in the "Hotkey Editor", in the Runtime Command Editor tab.

Alternatively, a simpler way would be to call the procedure "dR_setActiveTransformAxis", which is part of the modeling toolkit toolset. Like so:

    dR_setActiveTransformAxis 0; (for the X axis)
    dR_setActiveTransformAxis 1; (for the Y axis)
    dR_setActiveTransformAxis 2; (for the Z axis)

The procedure works on all manipulators, so this makes it possible to create a single shortcut for each axis independently from the manipulator. I use this at work every day and it's pretty handy!

A final tip (which I'm not sure is documented), after you have operated in a specific axis if you want to reset the manipulator just double tap the it's shortcut and that will do it (2x W, 2x E, 2x R).

Hope this was helpful. Have a nice day! 




GiacCol
Contributor
Contributor
Accepted solution

You can find what you are looking for under the "command" section of Maya's documentation.

Essentially in order to do this you need to edit the state of the manipulators, and you can do so by calling these commands:

    manipMoveContext; // for move
    manipRotateContext; // for rotate
    manipScaleContext; // for scale


You can run these commands with the flags -e (edit) and -cah (currentActiveHandle) and specifiy the axis with 0 (X), 1 (Y), 2 (Z) or 3 (Aligned to View) and end by specifying which manipulator you want to affect.


Like so:

    manipMoveContext -e -cah 0 Move;


You could then create a custom shortcut under the Runtime Command section of the Hotkey Editor for each manipulator, but that would mean 3 hotkeys for each manipulator (one for each axis), which would be pretty annoying to use in practice.


I've written a few lines of code that should do what you are actually looking for:

/* This sets the current manipulator to work only in the X axis ------------------------------ */

{
    // Query the current manipulator
    string $curManip = `currentCtx -q`;

    if ($curManip == "moveSuperContext")
    {
        manipMoveContext -e -cah 0 Move;
    }
    else if ($curManip == "RotateSuperContext")
    {
        manipRotateContext -e -cah 0 Rotate;
    }
    else if ($curManip == "scaleSuperContext")
    {
        manipScaleContext -e -cah 0 Scale;
    }   
}

 

/* This sets the current manipulator to work only in the Y axis ------------------------------ */

{
    // Query the current manipulator
    string $curManip = `currentCtx -q`;

    if ($curManip == "moveSuperContext")
    {
        manipMoveContext -e -cah 1 Move;
    }
    else if ($curManip == "RotateSuperContext")
    {
        manipRotateContext -e -cah 1 Rotate;
    }
    else if ($curManip == "scaleSuperContext")
    {
        manipScaleContext -e -cah 1 Scale;
    }   
}

 

/* This sets the current manipulator to work only in the Z axis  ------------------------------ */

{
    // Query the current manipulator
    string $curManip = `currentCtx -q`;

    if ($curManip == "moveSuperContext")
    {
        manipMoveContext -e -cah 2 Move;
    }
    else if ($curManip == "RotateSuperContext")
    {
        manipRotateContext -e -cah 2 Rotate;
    }
    else if ($curManip == "scaleSuperContext")
    {
        manipScaleContext -e -cah 2 Scale;
    }   
}

 

Assign each one to a shortcut and they should work as expected, regardless of the manipulator (so you only need 3 shortcuts).

As a final tip (and one which I'm not sure is documented anywhere), to reset the manipulator state just double tap it's assigned shortcut (2x W, 2x E, 2x R).

Hope that was helpful. Have a nice day!

GiacCol
Contributor
Contributor

I forgot to mention a couple of things!

After pressing the shortcut you've assigned to the script you need to use the middle-mouse button and drag (not the left click) or it wont work!

So, press your shortcut and then move, rotate or scale using middle-mouse button.

Alternatively, this functionality is somewhat already baked into the manipulators. You can press shift and middle-mouse drag and the manipulators will work on the axis that is most perpendicular to the camera (sorry if I'm not explaingin my self well). But since this functionallity is "view aligned" might not be as precise as a direct shortcut, which is what you were asking for.

Anonymous
Not applicable

Thank you so much i have no words to express my gratitude. its exactly what i was looking for but i could not find. 

GiacCol
Contributor
Contributor

No problem man, glad I could help!

Sorry for the double post, but first time it didn't go through (maybe servers on Sunday aren't as responsive) and I had to write a new one. Today the first one resurfaced.. go figure.

Glad you are enjoying the script, have a nice day!

paulo_faria_manpower
Community Visitor
Community Visitor

This should be implemented as a default shortkey in maya like blender, its veeery useful and in maya would be even better if you press w for move and X for move on X axis and the middle mouse to transform in X axis, if you press Y and Move with middle mouse, it translate in Y axis, the same for rotate and scale, but we need something like the gismo in lower left corner of the viewport showing the selected axis just to be sure

0 Likes