This script adds a VRay object ID tag or material ID tag and sets its value to any selected geometry, materials, or shading engines.
To Run: Select the geometry, materials, or shading engines you want to add an ID to then run the script.
#Object for VRay Maya version 1.0.0 #Should work with up to Vray 2.4 haven't gotten access to a later version to test #Bryanna London #!/usr/bin/env python #Adds object IDs to selected meshes or it will add a material Id to selected materials or shading engines import maya.cmds as cmds def idAssign(): #define selected objects, selected materials, and selected shading engines selectedObjs = cmds.ls(selection = True, dag = True, lf = True, visible=True, type = 'mesh') selectedMtls = cmds.ls(selection = True, materials = True) selectedShadingE = cmds.ls(selection = True, type = 'shadingEngine') selected = selectedObjs + selectedMtls + selectedShadingE #if nothing is selected give a warning message if not selected: cmds.confirmDialog( title = 'Warning', message = 'Nothing Selected. Nothing Done.', button = 'OK', defaultButton = 'OK') #Dialog Window if selected: idPrompt = cmds.promptDialog(title = 'VRay Object ID', message = 'Enter Object ID Number', button=['Add', 'Remove', 'Cancel'], defaultButton='Add', cancelButton='Cancel', dismissString='Cancel') #If Add is selected if idPrompt == 'Add': #Query prompt number = cmds.promptDialog(query = True, text = True) #Add vray object ID attribute for selectedObj in selectedObjs: cmds.vray("addAttributesFromGroup", selectedObj , "vray_objectID", 1) cmds.setAttr(selectedObj + '.vrayObjectID', int(number)) #Add vray material ID attribute to shaders for selectedMtl in selectedMtls: cmds.vray("addAttributesFromGroup", selectedMtl , "vray_material_id", 1) cmds.setAttr(selectedMtl + '.vrayMaterialId', int(number)) #Add vray material ID attribute to shading engine for selectedShading in selectedShadingE: cmds.vray("addAttributesFromGroup", selectedShading , "vray_material_id", 1) cmds.setAttr(selectedShading + '.vrayMaterialId', int(number)) #If Remove is selected if idPrompt == 'Remove': #Add vray object ID attribute for selectedObj in selectedObjs: cmds.vray("addAttributesFromGroup", selectedObj , "vray_objectID", 0) #Add vray material ID attribute to shaders for selectedMtl in selectedMtls: cmds.vray("addAttributesFromGroup", selectedMtl , "vray_material_id", 0) #Add vray material ID attribute to shading engine for selectedShading in selectedShadingE: cmds.vray("addAttributesFromGroup", selectedShading , "vray_material_id", 0) #Run the Script idAssign()
© 2016 Bryanna London