Hello everybody,
I'm modifying a script I've used in the past and am running into issues.
The goal is to have a for loop that creates a StingrayPBS shader, then checks the "Use Color Map" attribute.
The pain point is that the "Use Color Map" attribute doesn't seem accessible until after the loop is completed.
I run the script once and it creates a shader, but when I try to setAttr it says:
//Error: setAttr: No object matches name:
I run it twice, once a shader has already been created by the first run through, and it works.
I'm assuming it's some kind of scope issue, but here's the rub, I can select the shader from inside the loop, I can output a listAttr for it, but on the first run through, it's a different list of attributes, but again, it shows up on the second run.
Here's the segment of the code where it breaks down:
$StingrayName = $matName[0] + "_"+ $matName[1] + "_StingrayPBS";
shadingNode -asShader StingrayPBS -name $StingrayName;
setAttr ($StingrayName+".use_color_map") 1;
Replies
I don't do mel so can't really suggest a solution but if this were python i'd assign the created material to a variable and then act on the variable rather than making the assumption that the material exists.
I assume mel can do the same sort of thing