Adding ObjectID Pass to Render Output in Maya Part 2: The Script
In my previous post , Autodesk's article showed us how to create an ObjectId pass in our scene. In the last post I also posted a snippet of PyMel script that creates a unique Id number for each object so each one will turn up a uniquely different colour from its neighbour in the objectId pass. However the process still needed us to manually create a Mental Ray Output Pass in the camera's Mental Ray section. Since then I have gone on to write a PyMel script to automate the process. So here is the script. # -- code start -- from pymel.core import * def uniqObjIdAssign(): # Written by Patrick Woo # usage: # - make sure mental ray is loaded, and set as your current renderer # - select the camera # - then select all the objects to give unique objectIDs to, and run this script # for more info go to: # http://patrickvfx.blogspot.com/2014/11/adding-objectid-pass-to-render-output.html if ls(sl=True)[0].getShape().nodeType()=='came