is it possible pythonically to get the name of the imageplane node of the selected camera ?
I have managed to code to get the modelPanel name and get its camera
import maya.cmds as cmds
p=cmds.getPanel(wf=True)
print("Panel in foucs: ",str(p))
cam=str(cmds.modelEditor (p, q=True, camera=True))
print("Camera: ",cam)
cmds.select(cam)
print(cmds.pickWalk(direction='down' )[0])
now how can I get the name of imagePlane that is connected to the camera…
but the possibility remains their can be other different type of connections to camera and since its a list , the list could then be populated with other type of objects as well then what…
One simple way would be to check the type of the connected nodes. If its node type is ‘imagePlane’, it’s probably an image plane.
Since you can have multiple image planes on a single camera, this function returns a list:
import maya.cmds as cmds
def GetImagePlanes(cameraShape):
"""
Returns a list of image plane nodes connected to the given camera shape
node. If no image planes are connected, returns an empty list.
"""
assert cmds.nodeType(cameraShape) == 'camera'
sourceConnections = cmds.listConnections(cameraShape, source = True) or []
return [node for node in sourceConnections if cmds.nodeType(node) == 'imagePlane']