Changing arnold disp attributes on multiple objects


#1

Hi, I’ve found a python script that sets displacement and subDiv Arnold attributes for multiple object, im not familiar with python but i managed to add few more parameters without breaking it.
Unfortunately Marking menus only work with mel. Anyone out there that could help converting this script.
Python version

import maya.cmds as cmds

listSelection = cmds.ls( selection=True)
childrenSelection = cmds.listRelatives(listSelection, allDescendents=True, noIntermediate=True, fullPath=True)
geometryShapes = cmds.ls(childrenSelection, type="geometryShape")

for shape in geometryShapes:
    cmds.setAttr( shape + '.aiSubdivType', 1 )
    cmds.setAttr( shape + '.aiSubdivIterations', 2 )
    cmds.setAttr( shape + '.aiSubdivUvSmoothing', 2 )
    cmds.setAttr( shape + '.aiDispAutobump', 1 )
    cmds.setAttr( shape + '.aiAutobumpVisibility', 97 )

Here is my MEL version, its a modified script from the webs. It works but if anyone has more elegant solution let me know

    {
string $nodes[] = `ls -selection`;
for ($node in $nodes)
{
string $shapes[] = `listRelatives -shapes $node`;
    setAttr ($shapes[0] + ".aiSubdivType") (1);
    setAttr ($shapes[0] + ".aiSubdivIterations") (2);
    setAttr ($shapes[0] + ".aiSubdivUvSmoothing") (2);
    setAttr ($shapes[0] + ".aiDispAutobump") (1);
    setAttr ($shapes[0] + ".aiAutobumpVisibility") (97);
}
}

Cheers!