// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Procedure Name: // getPanelCamera // // Description: // Get the camera shapes in the model panel. // // Input Arguments: // None. // // Return Value: // An empty string list is returned if there is no camera. // proc string[] getStereoCameraShapes( string $cameraRig ) { int $numberOfCameras = 0; string $cameras[]; python("from maya.app.stereo import stereoCameraRig"); string $centerCam = python("stereoCameraRig.centerCam('"+$cameraRig+"')"); if (size($centerCam)) $cameras[$numberOfCameras++] = $centerCam; string $leftCam = python("stereoCameraRig.leftCam('"+$cameraRig+"')"); if (size($leftCam)) { // It's possible that the left or right are the same as the // center. Remove duplicates. if (!stringArrayContains( $leftCam, $cameras)) $cameras[$numberOfCameras++] = $leftCam; } string $rightCam = python("stereoCameraRig.rightCam('"+$cameraRig+"')"); if (size($rightCam)) { // It's possible that the left or right are the same as the // center. Remove duplicates. if (!stringArrayContains( $rightCam, $cameras)) $cameras[$numberOfCameras++] = $rightCam; } return $cameras; } proc string[] getCameraShapeName( string $camera ) { string $cameras[]; // A shape was found so use that. if (`objectType -isa camera $camera`) { $cameras[0] = $camera; } else { // Check the shape under a transform for a camera // Get current camera's shape string $cameraShapes[] = `listRelatives -shapes $camera`; if (size($cameraShapes) > 0) { $cameras[0] = $cameraShapes[0]; } } return $cameras; } global proc string[] getPanelCamera( string $modelPanel ) { int $numberOfCameras = 0; if (`modelPanel -exists $modelPanel`) { string $camera = `modelPanel -q -camera $modelPanel`; return getCameraShapeName( $camera ); } else { string $customEditor = `getCustomViewEditorFromPanel $modelPanel`; if ("" != $customEditor) { string $cameraRig = `modelEditor -q -camera $customEditor`; python("from maya.app.stereo import stereoCameraRig"); string $rigRoot = python( "stereoCameraRig.rigRoot('"+$cameraRig+"')"); if ($rigRoot != "") { return getStereoCameraShapes( $rigRoot ); } else if ( size($cameraRig) ) { return getCameraShapeName( $cameraRig ); } } } string $warnMsg = (uiRes("m_getPanelCamera.kNoValidCamera")); warning (`format -s $modelPanel $warnMsg`); return {}; }