python script to change Maya Renderable Camera in Render Settings



I am looking to write a python script to change the camera in the ‘Render Settings’.

I have tried the following:
cmds.setAttr(“frontShape.renderable”, False)
cmds.setAttr(“perspShape.renderable”, False)
cmds.setAttr(“sideShape.renderable”, False)
cmds.setAttr(“topShape.renderable”, False)
cmds.setAttr(‘cameraShape1.renderable’, True)

And although when I query the cameras, the settings are correct.
The RENDER SETTINGS tab does not change the Camera to Camera1. It still lists ‘Persp’ or whatever was there before, instead of changing the renderable camera to Camera1. Therefore Persp is what would render and not the camera I want.

Does anyone know what I am doing wrong?




The render settings window doesn’t update live with out a mel command if memory servers. Try running the script without that window open and open it after and see if that works. That is what seemed to work for me.