This script will go through all your selected geometry and assign your designated object ID number to them. So they render the same color in the object ID pass. This can be used with my script found here or you can create your own object ID pass with the aiUtility shader set to Object ID.
To Run: Select the objects you want to have the same ID number. Run Script set your number. This assigns the variable to the geometrys User Options setting. This works with my Arnold Object ID AOV found here:
#Arnold Matching IDs version 1.0.0
#For Maya. Tested in Maya 2014 & 2015 with Arnold 4.2.9.0
#Bryanna London www.bryannalondon.com
#!/usr/bin/env python
import maya.cmds as cmds
def specifyID():
selectedObj = cmds.ls(selection = True, dag = True, lf = True, visible=True, type = 'mesh')
#if nothing is selected give a warning message
if not selectedObj:
cmds.confirmDialog( title = 'Warning', message = 'Nothing Selected. Nothing Done.', button = 'OK', defaultButton = 'OK')
#Dialog Window
if selectedObj:
idPrompt = cmds.promptDialog(title = 'VRay Object ID', message = 'Enter Object ID Number', button=['Add', 'Remove', 'Cancel'],
defaultButton='Add', cancelButton='Cancel', dismissString='Cancel')
if idPrompt == 'Add':
#Query prompt
idNumber = cmds.promptDialog(query = True, text = True)
#If no value was entered send a warning
if idNumber == '':
cmds.confirmDialog( title = 'Warning', message = 'No Value Entered.', button = 'OK', defaultButton = 'OK')
else:
#Add Value entered as id value in User Options Variable
for selected in selectedObj:
cmds.setAttr(selected + '.aiUserOptions', 'id ' + idNumber , type = 'string')
#Remove Existing User Options Value
if idPrompt == 'Remove':
#Query prompt
idNumber = cmds.promptDialog(query = True, text = True)
#Remove User Options Value
for selected in selectedObj:
cmds.setAttr(selected + '.aiUserOptions', '' , type = 'string')
#Run Script
specifyID()
© 2016 Bryanna London