Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save blenderdeluxe/cd4a4a2eff0dc8fe6da929cdc9de64d6 to your computer and use it in GitHub Desktop.
Save blenderdeluxe/cd4a4a2eff0dc8fe6da929cdc9de64d6 to your computer and use it in GitHub Desktop.
Add vray subdivision to multiple objects in Maya
#Run script in python view on script editor
#Select all objects that need apply vray subdivision
#Execute in maya python console makeVrayAttributes(1)
import maya.cmds as cmds
import maya.mel as mel
def makeVrayAttributes(startID=1):
sel = cmds.ls(sl=1)
currentID=startID
for i in sel:
# get renderable shape nodes relative to transform, iterate through and apply subdivision
shapes = cmds.listRelatives(i,s=1,ni=1)
if shapes:
for s in shapes:
melCmd = "vray addAttributesFromGroup "+s+" vray_subdivision 1"
mel.eval(melCmd)
melCmd = "vray addAttributesFromGroup "+s+" vray_subquality 1"
mel.eval(melCmd)
# apply object ID to xform. i don't like giving individual shapes IDs.
melCmd = "vray addAttributesFromGroup "+i+" vray_objectID 1"
mel.eval(melCmd)
cmds.setAttr(i+'.vrayObjectID',currentID)
currentID += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment