Fast way to switch between perspective & a camera ?


Just wondering if anyone would know how to set up a way to switch between perspective & camera in one viewing area quickly ?
I’m getting fed up of clicking on panels --> perspective --> persp/cam1 etc


You can always switch back to persp cam quickly by holding SPACE and LMB-stroking UP (HotBox MM) as for switching quickly to a different camera, how would you tell Maya which camera you want to switch to?

if you select any camera and pick: Panels > Look Through Selected it does what you want, but the main thing in this case is that it also prints out the command in the scriptEditor History:

lookThroughModelPanelClipped camera1 modelPanel4 0.001 1000;

If you put this line of code on a shelf button, it would change viewport 4 (default persp view) into camera1 each time you pressed it. You could even enhance it like so:

lookThroughModelPanelClipped camera1 `getPanel -wf` 0.001 1000;

so it worked on whatever viewport you were using.

you can also MMB-drag any camera from the outliner onto a viewport, which may be the best solution for you.



Hey Nathan,

Thank you for the tips and insight !
Very handy :applause: (especially the MMB drag!)

Now I wonder if I can can groups/bins in my hypershade (possibly can, just newish to maya). :lightbulb
I don’t mean the ones like under the ‘create tab’ I want actual folders, or at least a shortcut to bins on the top instead of pressing that blasted tab :scream:


never mind. MMB was already mentioned.


Yep, thanks Nathan from another newish user.

That MM bit is a jewel!:love:



Here’s the script that I use for this so I can jump back and forth between a shot cam and the default perspective camera, something I do a lot when animating characters (I have it tied to a hotkey).

This version cycles through perspective cameras only :

  //Switch Perspective Cameras
  $currentCamera = `lookThru -q`;
  string $allCameras[];
  $allCameras = `listCameras -p`;// This will select perspective cameras only
  int $nextCamera;
  if($currentCamera == $allCameras[$pos]) $nextCamera = $pos+1;
  if($nextCamera>=size($allCameras)) $nextCamera = 0;
  lookThru $allCameras[$nextCamera];

And here’s a variation that cycles though every available camera (I don’t use this myself, I prefer the one above).

  //Switch All Cameras
  $currentCamera = `lookThru -q`;
  string $allCameras[];
  $allCameras = `listCameras`;// This will select all cameras
  int $nextCamera;
  if($currentCamera == $allCameras[$pos]) $nextCamera = $pos+1;
  if($nextCamera>=size($allCameras)) $nextCamera = 0;
  lookThru $allCameras[$nextCamera];

Probably not the most efficient coding as I’m still pretty new to MEL but hey it works ; )



You can also add your shot cam to the center spacebar marking menu.
Not in front of maya right now, there is a marking menu editor and with that you can add extra cameras for the other directions of the camera marking menu.
The command you need to enter is:
lookThru cameraShape

Replace cameraShape with whatever your desired camera shape is.
My default shot camera is always cam_render so I put:
lookThru cam_renderShape

Just further proof that there are a million ways to do things in maya.


Absolutely : )

The script I posted above uses the lookThru command too, it builds a list of all the perspective cameras first and then cycles through them each time you run it, so if you just have the default perspective camera and a shot cam it will toggle back and forth between those two. The handy thing about creating the list of available perspective cameras is that it doesn’t need to know the name of the camera in advance, so the command will work in any Maya scene.



Awesome info guys, really useful !


Here is my solution to problem.
Make marking menu item in your standard hotbox center MM for example cam1 and put this script in there.

string $cam1;
int $mods = `getModifiers`;
if ($mods==1) 
$sel=`ls -sl`;
lookThru $cam1;

So when you hold shift this will assign selected camera to this menu item , else will look through camera.


i think i wrote this when i used maya 1.0 since i already disliked the way to change to/between non standard cameras.

i assigned it to SHIFT+ALT+c and feel like crippled whenever i get to a maya installation without it :slight_smile:

just lists all cameras in a small window. by pressing the button the camera is viewed.



int $selSize;
string $camSelection[];
string $creationString = "";
string $buttonString = "";
$camSelection = `listCameras`;
$selSize = size($camSelection);
for ($i=0; $i<$selSize; $i++)
$creationString += ("string $button"+$i+" = `button -al \"center\" -label ($camSelection["+$i+"])`;
$buttonString += ("button -edit -command (\"changeCam \" + $button"+$i+") $button"+$i+";
if(`window -q -ex LXCamSelectionWin`) deleteUI LXCamSelectionWin;
window -title "Camera Selection" -widthHeight 150 100 LXCamSelectionWin;
columnLayout -adj 1 -cat "both" 5;
showWindow LXCamSelectionWin;
proc changeCam (string $whichButton) 
string $currentLabel;
$currentLabel = `button -query -label $whichButton`;
lookThru ($currentLabel);

and there is at least 1.000.001 ways to do things :slight_smile:


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.