MEL How-To #19 | ||
| ||
How can I determine if a camera other than the default cameras has been created if I don't know the name of the new camera?By default Maya creates four cameras for a scene: persp front side top The first camera, ‘ It is not possible (without effort) to rename or delete these default cameras as they are flagged as read-only. You can determine if a camera is read-only -- or rather if it's flagged as one of the default startup cameras -- by querying the ‘ camera -q -startupCamera persp; // Result: 1 // Knowing this, it is possible to get a list of all cameras, query each for the ‘
proc string[] getExtraCameras()
{
string $extraCameras[];
int $numExtraCameras = 0;
string $cameras[] = `ls -cameras`;
for ( $camera in $cameras )
{
// If this camera is not a startupCamera, add it to the array
if ( !`camera -q -startupCamera $camera` )
$extraCameras[$numExtraCameras++] = $camera;
}
return $extraCameras;
}
// Get a list of all non-startup cameras
string $extraCameras[] = getExtraCameras();
if ( size( $extraCameras ) )
{
print ( "The following cameras have been added to the scene:\n" );
print $extraCameras;
}
else
print ( "No extra cameras added to the scene.\n" );
| ||
| Copyright ©2005 by Bryan Ewert, maya@ewertb.com Maya is a Registered Trademark of Alias |