I know you can query which camera is associated with a particular panel. But, is there a way you can do it the other way around?
I want to be able to see what panel is associate with a particular camera.
Example:
getPanel -q mainCamera;
// modelPanel1
Thanks for the help yall
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.