Create a Camera and Autosetup for Rendering

When rendering with Mental Ray I always use a dedicated RenderCam. To create this camera I usually do the following

  1. Create the Camera
  2. Rename the Camera to “RENDER_CAM”
  3. Add the Lens shader “miaexposurephotographic”
  4. Look through the Camera, Position it
  5. Do Test Renders

What really bothered me about this process, is that these steps are always the same and for Animations, I forgot to set this camera as the RenderCam for Batch Render. I created this short script to do these steps automatically:

import pymel.core as pm

def createRenderCam(name = "RENDER_CAM", exposure = True):
    Creates a camera and renames it

    str name: name of the camera
    bool exposure: connect a mia\_exposure\_photographic node to the camera
    if not pm.objExists(name):
        cam =\[0\]
        pm.rename(cam, name)
        \[cam.renderable.set( for cam in\]
    cam = pm.PyNode(name)

    if exposure:
        if not cam.miLensShader.isConnected():
            node = pm.createNode("mia\_exposure\_photographic")
            pm.connectAttr(node.message, cam.miLensShader, force=True)