Wednesday, June 17, 2020

Add vray subdivision node to all selected objects in Maya MEL



Here is a little MEL code snippet to add an individual vray subdivision node to each of your selected objects in Maya.

Simply select all your geo, paste into the MEL script line in maya and hit enter!


{
string $sel[] = `ls -sl -dag -s`;
for ($each in $sel){
 if (`nodeType $each`=="mesh"){ 
  print ("// adding VRay subdivision attributes to "+$each+"\n");
  vrayAddAttr($each, "vraySubdivEnable");
  vrayAddAttr($each, "vraySubdivUVsAtBorders");
 }
}
}


Alternatively, this tip from Raymond in the comments below. If you would like ONE vray subdivision node to effect all objects. Which is easier to control simply:

Select your objects, then: Create > VRay > VRay Displacement > Apply Single VRayDisplacement Node To Selection

Then on the VRayDisplacement node, in the Attribute Editor: Attributes > VRay > OpenSubDiv (or whatever you want)