Wednesday, February 19, 2014

Maya trick: Hide manipulator tool with a hotkey


Hide Manipulator Tool in action


How the hotkeys work when adding objects to your selection


I recently created a set of hotkeys in Maya that make the transform manipulators disappear when I press a certain hotkey. This is useful when you have an object or control selected and you want to select another one that is covered (or inside) the manipulator itself. The problem is better explained in the image below.

Main problem I have

There are many workarounds on this issue, like switching to the selection tool and then switch back to my previous tool, or decreasing the size of the manipulator itself. All these alternatives are valid but for me they didn't work. I guess I'm too used to 3ds max, where you can select objects through the manipulator without a problem.

Anyhow, I have a US keyboard, so I mapped the new hotkeys to the \ and | keys (where | = SHIFT + \). I mention the type of keyboard because the keys I chose are just beside the SHIFT key, but if you have a different type of keyboard you can map them wherever you see fit.

US keyboard configuration (Image: Link)


The way these hotkeys work is as follows:

\ , change my selection
This hotkey will hide the manipulator and let me select another object that is covered by the manipulator.

| , add to my current selection
This hotkey will hide the manipulator and allow me to add other objects to my current selection. This key is the equivalent of pressing SHIFT + \ (by default, SHIFT is used to add objects to your selection).

In both cases, when you release the keys, the previous manipulator will reappear. This way you will be able to select objects that are inside the manipulator area (especially the rotation tool) and add objects without switching to another tool.

How to install it


First, open the Hotkey Editor (Window\Settings/Preferences\Hotkey Editor)

Hotkey Editor with new commands

Click on New to create a new command. Add the following information for each of the available fields:

Command Name: _HideToolChangeSelectionPress
Description: Hides the current tool when selecting another object
Category: Selection
Language: MEL

Command:

overrideModifier -press Shift;
string $_HTPrevCtx = `currentCtx`;
SelectToolOptionsMarkingMenu;
MarkingMenuPopDown;

Repeat the process for the other commands:

Command Name: _HideToolChangeSelectionRelease
Description: Shows the last tool after selecting another object with special modifier
Category: Selection
Language: MEL

Command:

overrideModifier -release Shift;
if ($_HTPrevCtx == "moveSuperContext") {
    TranslateToolWithSnapMarkingMenu;
    MarkingMenuPopDown;
}
if ($_HTPrevCtx == "RotateSuperContext") {
    RotateToolWithSnapMarkingMenu;
    MarkingMenuPopDown;
}
if ($_HTPrevCtx == "scaleSuperContext") {
    ScaleToolWithSnapMarkingMenu;
    MarkingMenuPopDown;
}

Command Name: _HideToolMultipleSelectionPress
Description: Hides the current tool when selecting multiple objects
Category: Selection
Language: MEL

Command:

overrideModifier -press Shift;
string $_HTPrevCtx = `currentCtx`;
SelectToolOptionsMarkingMenu;
MarkingMenuPopDown;

Command Name: _HideToolMultipleSelectionRelease
Description: Shows the last tool after selecting multiple objects with special modifier
Category: Selection
Language: MEL

Command:

overrideModifier -release Shift;
if ($_HTPrevCtx == "moveSuperContext") {
    TranslateToolWithSnapMarkingMenu;
    MarkingMenuPopDown;
}
if ($_HTPrevCtx == "RotateSuperContext") {
    RotateToolWithSnapMarkingMenu;
    MarkingMenuPopDown;
}
if ($_HTPrevCtx == "scaleSuperContext") {
    ScaleToolWithSnapMarkingMenu;
    MarkingMenuPopDown;
}

Once all the commands are created assign them as follows:

Hotkey: \
Direction: Press
Command: _HideToolChangeSelectionPress

Hotkey: \
Direction: Release
Command: _HideToolChangeSelectionRelease

Hotkey: |
Direction: Press
Command: _HideToolMultipleSelectionPress

Hotkey: |
Direction: Release
Command: _HideToolMultipleSelectionRelease

I created this tool to improve my workflow. If you have any comments or suggestions, let me know.

Enjoy!

References:
http://forums.cgsociety.org/archive/index.php/t-230516.html
http://www.raffael3d.com/maya_s_tutorial.php

1 comment:

Amaia said...

In Maya if you hit the Q, it does hide the manipulator icon.