Wednesday, June 4, 2008

Custom Hotkey - Nurbs Controller On/Off

Here is a handy hotkey that I use all the time and that can speed up your workflow.

When I have a scene open, I divide my window setup like this:

The outliner on the top right, so I can see what I have in my scene, constraints, locators, etc. whatever I set up for the scene. On the right, the render camera, because that's what I am animating to. Bottom left my graph editor for sweet animation tweaking and to the right my perspective camera to move around my scene.
Speaking of moving. Ever had the problem that you would suddenly move your render camera around because you thought that it was the perspective camera? And then you loose the position because you didn't keyframe the settings? The moment I decide on the camera, I lock all the channel attributes, just to be safe.

So I'm looking at my scene through the render camera and see that the arc on the head turn is not quite working. Now I want to select the head controller so I can tweak the animation. Either you select the CON in your character GUI, or your switch to a different camera that has your controller curves set to visible, or in the camera panel view you go to show>Nurbs Curves, etc. Most of the time it involves a few steps and it would be cool to have it faster.

So you can set up a hotkey, so that when you push a button (and hold it) the curves appear and when you release the key the curves are gone. I'm a lefty so my example layout is based on that but it obviously works for righties.
Being left handed means that in my work setup, my right hand is on the keyboard with my index on the "W"and ending with my middle finger on "R", and my thumb is on "Alt". That way I control the camera and the translate, rotate and scale functions. My pinky and index would control two other functions but I rarely use them. With that finger layout I chose the key "g" for my "show nurbs" hotkey, because I only have to lower my finger down to that key, it's very close and accessible. When I push "g" the curves appear, when I let go the curves disappear.

How do I set this up? First open your script editor:

Then in that window go to Script>Echo all commands:

and Edit>Clear All so that your script editor is clean and empty:

Now you have to decide for which window this hotkey will work (or you set it up for all windows, but I'll go ahead with just one). As you can see above, my rendercamera is always in the upper right window, which is panel 4. The panel layout is like this:

Seems kinda odd, but that's what the script editor is telling me... So I'm going for #4. What you do you know is go to Show>NURBS Curves (my check mark was off). Then look at your script editor and this is what you get:

The line that's important for the hotkey modification is "modelEditor -e -nurbsCurves 1 modelPanel4;". The #1 means on, when you turn the curves off, you'll see a 0. And the window that I chose for that is modelPanel4.

You then go into your Hotkey Editor by clicking Window>Settings/Preferences>Hotkeys...

In there you will scroll down to User. in the Catogories section.

Then click on New, give it a name (I gave it nurbson), and paste the line modelEditor -e -nurbsCurves 1 modelPanel4; into the Command box. Click Accept. In the "Assign New Hotkey" section, I put in g for the Key. The Direction is Press. Assign that. You might get a message saying that another command is already assigned to g, but I just ignored that. Repeat all this with a new New command (called nurbsoff). Name it g as well but for the Direction you select Release. Assign all that and Save it. You are good to go.

So now you go and push and release that button with panel4 selected and your curves will appear and disappear, allowing for quick selections.

1 comment:

Jean-Denis Haas said...

adding "coop"'s comment:

//this is a good toggle for whatever window you have selected
//toggles visibility of nurbs, paste in as a user hotkey
$currentPanel = `getPanel -withFocus`;
string $panelType = `getPanel -to $currentPanel`;
if ($panelType == "modelPanel")
int $on_flag = `modelEditor -q -nurbsCurves $currentPanel`;
if ($on_flag == 0)
modelEditor -e -nurbsCurves 1 $currentPanel;
modelEditor -e -nurbsCurves 0 $currentPanel;