Sunday, August 30, 2009

Hotkey view changes, isolate select and Hidden line shade view

In Maya, I never really liked having to toggle my 3d view to perpspective, front, side and top using the space bar menu or to have to dig into a panel menu to isolate my selection (I hate doing hide unselected... but that's me) ... I prefer using hotkeys for those.

Unfortunatly there is no way to hotkey these without having to create the commands using mel.
Fortunatly creating a new hotkeyable command in Maya is really easy.

Here are a few hotkey commands I like to create for Maya:

Let's create the first hotkey command ... the toggle perspective view command.
First, open the Hotkey Editor.
1. In the Category section to the left, select the User Category.
2. Create a new entry by pressing New in the bottom part of the editor
3. Enter a name for the new command
4. In the command section copy paste this command: switchModelView Perspective;
5. Hit Accept to save the new command.
Now you can assign any hotkey to the command to toggle the current view to a perpspective view!

It should look something like this:

Repeat step 2 to 5 using the following commands for the front, side and top view
switchModelView front;
switchModelView side;
switchModelView top;

I personnaly assign each command to Alt+1, Alt+2, Alt+3 and Alt+4

Now for the Isolate selection hotkey ...
The process is the same a above. Here is the mel script you need to copy in the command section:
string $panel = `getPanel -withFocus`;
int $panelStatus = `modelEditor -q -viewSelected $panel`;
if ( $panelStatus == 0 ) {
enableIsolateSelect $panel 1;
isolateSelect -state 1 $panel;
isoSelectAutoAddNewObjs $panel 1;
} else {
enableIsolateSelect $panel 0;
isolateSelect -state 0 $panel;
}

I assign this command to the "i" hotkey ... select one or more objects then hit "i" to go to isolate selection mode, press "i" again to get out of isolate selection mode.
Works like a charm and is way faster than doing hide unselected.

Now ... for those of you that worked in Softimage, you are probably missing the hidden line shaded mode.

Lucky you... here is how to do it in Maya:

For this one you will need to create 2 commands, one that will set the view in Hidden Line, one that will put it back to normal Maya shade. And you will need to override the default shade hotkey with the later command.

First, create the hidden line command:
Create a new command like the example above ... enter displayHiddenLine as the name of the command ... in the command section enter this mel script (the tabing might get messy because of the copy/paste, but fear not the command will work) :
{
string $currentPanel = `getPanel -underPointer`;
if ("" == $currentPanel) {
$currentPanel = `getPanel -withFocus`;
}
if ("" != $currentPanel) {
string $panelType = `getPanel -typeOf $currentPanel`;
if ($panelType == "modelPanel") {
modelEditor -edit -displayAppearance "smoothShaded" -displayTextures off
-displayLights "none" -wos 1 $currentPanel;
} else if (`isTrue "MayaCreatorExists"` && `scriptedPanel -exists $currentPanel`
&& `scriptedPanel -query -type $currentPanel` == "dynPaintScriptedPanelType") {
dynPaintEditor -edit -displayTextures 0 -displayAppearance "smoothShaded"
-displayLights "default" $gDynPaintEditorName;
} else if ($panelType == "scriptedPanel") {
string $scriptedType = `scriptedPanel -q -type $currentPanel`;
if ($scriptedType == "referenceEditorPanel") {
global string $gReferenceEditorModelEditor;
modelEditor -edit -displayAppearance "smoothShaded" -displayTextures off -displayLights "default" $gReferenceEditorModelEditor;
}
}
}
};


You will also need to create the new toggle shade command to replace the default one:
Create another new command ... enter displayShadedNew as the name of the command ... in the command section enter this mel script:
{
string $currentPanel = `getPanel -underPointer`;
if ("" == $currentPanel) {
$currentPanel = `getPanel -withFocus`;
}
if ("" != $currentPanel) {
string $panelType = `getPanel -typeOf $currentPanel`;
if ($panelType == "modelPanel") {
modelEditor -edit -displayAppearance "smoothShaded" -displayTextures off
-displayLights "default" -wos 0 $currentPanel;
} else if (`isTrue "MayaCreatorExists"` && `scriptedPanel -exists $currentPanel`
&& `scriptedPanel -query -type $currentPanel` == "dynPaintScriptedPanelType") {
dynPaintEditor -edit -displayTextures 0 -displayAppearance "smoothShaded"
-displayLights "default" $gDynPaintEditorName;
} else if ($panelType == "scriptedPanel") {
string $scriptedType = `scriptedPanel -q -type $currentPanel`;
if ($scriptedType == "referenceEditorPanel") {
global string $gReferenceEditorModelEditor;
modelEditor -edit -displayAppearance "smoothShaded" -displayTextures off -displayLights "default" $gReferenceEditorModelEditor;
}
}
}
};

Now you need to assign the displayShadedNew command to the 5 hotkey so that it override the default Maya hotkey then assign displayHiddenLine to any hotkey ... i personnaly use Shift+5.

I hope that you like these simple tips, they are quite simple but they can surprisingly speed up your work.

Cheers

3 comments:

  1. great man
    i have been trying to do this for ages.
    is it possible to display the hidden line but not in "flat shaded mode" and vice versa?

    ReplyDelete
  2. yes it is possible, the script set shaded options, in the case of hidden line, it is shaded ON, wireframe on shaded ON, lights NONE.

    Which is this line:
    modelEditor -edit -displayAppearance "smoothShaded" -displayTextures off -displayLights "none" -wos 1 $currentPanel;

    by setting this line to this:
    modelEditor -edit -displayAppearance "smoothShaded" -displayTextures off -displayLights "default" -wos 1 $currentPanel;

    you will get shaded, no texture, wireframe on shaded and default lights

    let me know if you need more help.

    ReplyDelete
  3. it works like a charm!
    thanks alot for these useful lines.

    ReplyDelete

Note: Only a member of this blog may post a comment.