This is a very useful script when working with cameras in Maya. It moves the selected camera to your current view and parents it to that camera (except when it's the persp-camera).
Usage: Select the camera you want to move to the current view
Code: Select all
{
// Author: Luigi Tramontana @ Craft Animations
// MCP: Move Camera and Parent selected camera
// Usage: Select the camera you want to move to the current view
string $currPanel = `getPanel -withFocus`;
string $currCamera = `modelPanel -q -camera $currPanel`;
// Save the current position of the current camera.
string $homeName = `cameraView -camera $currCamera`;
// Get selection list. Gets listed in the selection order.
string $nodes[] = `ls -selection`;
if( `camera -q -orthographic $currCamera` == 0) // if not orthographic continue
{
// Make the selected camera identical to the current view.
cameraView -e -camera $nodes[0] -sc $homeName;
// Look through the selected camera.
lookThroughModelPanel $nodes[0] $currPanel; //lookThroughModelPanelClipped $nodes[0] $currPanel 0.001 1000;
if( `strcmp $currCamera persp` != 0) // if not persp camera, parent selected camera to it
{
// Parent the selected camera to the current.
parent $nodes[0] $currCamera;
}
}
};