March 2019: ewertb.soundlinker.com is getting relocated to ewertb.mayasound.com, please update your bookmarks.

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