(HELP) MEL script to assign a new Vraymtl material based on that objects name (HELP)


#1

string $selectedObjs[] = ls -sl; //get selected objects
for ($obj in $selectedObjs){ //iterate on selected objects
string $newMat = shadingNode -asShader "Vraymtl"; //create a vraymtl
string $rnMat = rename $newMat ($obj + "_m"); //rename new material based on object [optional]
string $newSG = sets -renderable true -noSurfaceShader true -empty -name ($rnMat + "SG"); //create a shading group
connectAttr -f ($rnMat + “.color”) ($newSG + “.surfaceShader”); //connect shading group to vraymtl
sets -e -forceElement $newSG $obj; //connect material to object
}

I want to use the above script, but I want to create it with vraymtl material.
Can anyone fix this by modifying this script??