This script returns which panels are associated with a particular camera (in this case: persp).
Mel version:
proc string[] getPanelFromCamera(string $cameraName){
string $listPanel[];
for( $panelName in `getPanel -type modelPanel`){
if( `modelPanel -query -camera $panelName` == $cameraName){
$listPanel[size($listPanel)] = $panelName;
}
}
return $listPanel;
}
print `getPanelFromCamera("persp")`;
Python version:
import maya.cmds as cmds
def getPanelFromCamera(cameraName):
listPanel=[]
for panelName in cmds.getPanel( type="modelPanel" ):
if cmds.modelPanel( panelName,query=True, camera=True) == cameraName:
listPanel.append( panelName )
return listPanel
print getPanelFromCamera("persp")
Note:
I'm usually don't script in mel, so the mel version of this code is a litteral translation from the python version. I also thought that the Python version might be useful for future readers.