MEL How-To #13

Back · Previous · Next Maya

How do I determine the name of the camera for the currently active layout panel?

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`;
  }

  return $camera;
}