I am looking for a keyboard shortcut that will cycle between tools in the toolkit.
i.e. Each press of the "`" key would cycle through the tools: Select, Move, Rotate, Scale, Select, Move, Rotate, Scale etc.
Suggestions welcomed!
*Reason Being; I would like to assign the Touch Ring of my Wacom Cintiq 24HD to cycle through these tools.
Thank You in advance. Cheers!
Solved! Go to Solution.
Solved by reid.j.w. Go to Solution.
You can try this - add this mel in Hotkey Editor.
int $Toolkit_Cycling;
$Toolkit_Cycling++;
if ($Toolkit_Cycling == 5) {$Toolkit_Cycling =1;}
switch ($Toolkit_Cycling) {
case 1:
SelectToolOptionsMarkingMenu;
break;
case 2:
TranslateToolWithSnapMarkingMenu;
break;
case 3:
RotateToolWithSnapMarkingMenu;
break;
case 4:
ScaleToolWithSnapMarkingMenu;
break;
}
By the way you can edit this mel and add any tools as your want .
Thank You Tony Su!
In my learnings, I had created an if statement based mel script that was operable. However, I like the option that you have provided much more.
I am currently tweaking your script and will follow up with my solution.
Regards and Cheers!
Since I will ultimately be using the Touch Ring of my Cintiq 24HD, I will need to be able to scroll downwards and upwards through the tools. Therefore 2 hotkeys needed to be created.
This is my first take at mel scripting, and based on the suggestion of Tony Su, this is what I came up with that works great (so far).
1) CycleToolsDown Command (using the Alt+2 hotkeys) with the following mel script:
if (`whatIs "$CycleCount"` == "Unknown"){ global int $CycleCount; } if ($CycleCount == 0){ MoveTool; $CycleCount = 3; }else if (($CycleCount >= 1) && ($CycleCount <=4)){ switch ($CycleCount){ case 1: SelectTool; $CycleCount = 2; break; case 2: MoveTool; $CycleCount = 3; break; case 3: RotateTool; $CycleCount = 4; break; case 4: ScaleTool; $CycleCount = 1; break; default: MoveTool; $CycleCount = 3; break; } }else{ MoveTool; $CycleCount = 3; }
-----------------------------------------------------
2) CycleToolsUp Command (using the Alt+1 hotkey) with the following script:
if (`whatIs "$CycleCount"` == "Unknown"){ global int $CycleCount; } if ($CycleCount == 0){ ScaleTool; $CycleCount = 1; }else if (($CycleCount >= 1) && ($CycleCount <=4)){ switch ($CycleCount){ case 1: RotateTool; $CycleCount = 4; break; case 2: ScaleTool; $CycleCount = 1; break; case 3: SelectTool; $CycleCount = 2; break; case 4: MoveTool; $CycleCount = 3; break; default: MoveTool; $CycleCount = 3; break; } }else{ MoveTool; $CycleCount = 3; }
Please feel free to critique!
I did try to make this script in my scripts directory and simply call it from the Hotkey editor, however, I got a little hung on getting the $CycleCount variable to keep its value. I had to suffice with this solution for now.
Thanks again Tony for the kickstart!
(For future reference) Here is my solution which allows a hotkey to cycle between the Select, Translate, Rotation and Scale tools.
In addition, I added the ability to change the Move and Scale tools Axis between Object and World.
I have button 1 of the cintiq 24hd touchring assigned to cyleAxis. Button 3 of the cintiq 24hd touchring assigned to cycleTool.
There are 6 mel scripts total, and I added them to my ...maya\2015-x64\scripts directory.
*I'm sure that I should have done this in python, however, it was my first stab at mel scripting and I wanted to explore and learn.
userSetup.mel
//Name mel script userSetup. //Defines custom user commands at application startup. // // allGlobalVars();
allGlobalVars.mel
//Name mel script allGlobalVars. //Declare all global variables // // global proc allGlobalVars(){ global int $g_currentTool; global int $g_select; global int $g_move; global int $g_rotate; global int $g_scale; //initialize variables initGlobalVars(); }
initGlobalVars.mel
//Name mel script initGlobalVars. //Initialize custom global variables. // // global proc initGlobalVars(){ global int $g_select; global int $g_move; global int $g_rotate; global int $g_scale; //Assign tool numbers to tools. $g_select = 1; $g_move = 2; $g_rotate = 3; $g_scale = 4; }
cycleTool.mel
//Name mel script cycleTool. //Cycles between Select, Move, Rotate and Scale. //Use 2 hotkeys with command being cycleTool($g_currentTool, "UP or DOWN"). // global proc cycleTool(int $tool, string $direction){ global int $g_currentTool; global int $g_select; global int $g_move; global int $g_rotate; global int $g_scale; if ($direction == "UP"){ switch ($tool){ case 0: ScaleTool; $g_currentTool = $g_scale; break; case 1: ScaleTool; $g_currentTool = $g_scale; break; case 2: SelectTool; $g_currentTool = $g_select; break; case 3: MoveTool; $g_currentTool = $g_move; break; case 4: RotateTool; $g_currentTool = $g_rotate; break; default: ScaleTool; $g_currentTool = $g_scale; print "EXCEPTION ...is scale tool from cycleTool's UP default switch\n"; break; } }else if ($direction == "DOWN"){ switch ($g_currentTool){ case 0: MoveTool; $g_currentTool = $g_move; break; case 1: MoveTool; $g_currentTool = $g_move; break; case 2: RotateTool; $g_currentTool = $g_rotate; break; case 3: ScaleTool; $g_currentTool = $g_scale; break; case 4: SelectTool; $g_currentTool = $g_select; break; default: print "EXCEPTION ...is current tool from Down's default switch\n"; MoveTool; $g_currentTool = $g_move; break; } }else{ print "EXCEPTION ...must supply a direction to cycleTool.\n"; } }
cycleAxis.mel
//Name mel script cycleAxis. //Cycles the move axis of either the Move or Scale tool. //Create 1 hotkey using the command cycleAxis(). // global proc cycleAxis(){ global int $g_currentTool; global int $g_select; global int $g_move; global int $g_rotate; global int $g_scale; if ($g_currentTool == $g_move){ int $CycleMove = `manipMoveContext -q -mode Move`; if ($CycleMove == 0){ //turn to object manipMoveContext -e -mode 2 Move; }else if ($CycleMove == 2){ //turn to world manipMoveContext -e -mode 0 Move; }else{ //turn to world manipMoveContext -e -mode 2 Move; } }else if($g_currentTool == $g_scale){ int $CycleScale = `manipScaleContext -q -mode Scale`; if ($CycleScale == 0){ //turn to object manipScaleContext -e -mode 2 Scale; }else if ($CycleScale == 2){ //turn to world manipScaleContext -e -mode 0 Scale; }else{ //turn to world manipScaleContext -e -mode 2 Scale; } }else{ pickTool(); } }
pickTool.mel
//Name mel script pickTool. //Prompts user to select either Move or Axis tool for //cycling the Move Axis options. // global proc pickTool(){ global int $g_currentTool; global int $g_move; global int $g_scale; $response = `confirmDialog -title "Cycle Tools Axis" -message "Please choose Tools Axis to modify." -button "Move Axis" -button "Scale Axis"`; if ($response == "Move Axis"){ MoveTool; $g_currentTool = $g_move; cycleAxis(); }else if($response == "Scale Axis"){ ScaleTool; $g_currentTool = $g_scale; cycleAxis(); } }