Last active
October 30, 2017 04:39
-
-
Save jm991/e9611f369c59e6139399207d9e899b7d to your computer and use it in GitHub Desktop.
Find out which camera you are working with
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--------------------------------------------------------------------------------- | |
// Source: https://acaciaecho.wordpress.com/2011/08/05/maya-get-current-camera/ | |
// Author: Zhang Jian | |
// Date: 08-05-2011 | |
// | |
// Description: | |
// Find out which camera you are working with. Focus on a model panel, | |
// in which you can have a camera to tumble/pan/zoom, and run getCurrentCamera, | |
// you will have the transform name of the camera. | |
// If you are in some other type of panel, say outliner, empty string will be returned. | |
// Installation: | |
// 1. Copy getCurrentCamera.mel to C:\Users\[USER]\Documents\maya\[MAYAVERSION]\prefs\scripts\jm991 | |
// 2. Restart maya | |
global proc string getCurrentCamera() | |
{ | |
string $camera; | |
// First get the panel that currently has focus | |
string $panel = `getPanel -wf`; | |
// Compare the panel's type to confirm it is a "modelPanel" | |
if ( "modelPanel" == `getPanel -to $panel` ) | |
{ | |
// Get the name of the camera using the ‘modelEditor’ command | |
$camera = `modelEditor -q -camera $panel`; | |
} | |
if($camera == "") | |
return ""; | |
if(`nodeType $camera` == "camera") | |
{ | |
string $rels[] = `listRelatives -p $camera`; | |
$camera = $rels[0]; | |
} | |
return $camera; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Remove the ".c" from the filename when you download this (git doesn't support .mel syntax highlighting)