I've been working on a little tool to help my workflow here (thanks to all of you who have answered my questions so far) and am so close to done I can taste it, except for this one issue. In my UI I have a "textScrollList" which basically lists all of the software materials (e.g. lambert, blinn, phong, blah blah). I want to create the material that is selected in that list when I hit apply.
When i print the query from the UI, it does correctly print "lambert" (or whatever other material I choose) so I don't think thats the issue.
I'm still very new to MEL, it seems to me like the below should create the new material - but it fails miserably.
//// here's an excerpt from the script
string $SWmaterial[] = textScrollList -q -si MaterialType;
shadingNode -asShader $SWmaterial;
Which gives me the error:
// Error: line 391: Invalid argument: lambert //
If I replace the variable $SWmaterial with "lambert" that line creates the lambert shader no problem. Since $SWmaterial is returning "lambert" when its queried, why doesn't this work?
I have tried simplifying the problem and it seems to works just fine:
//// simplified version
string $SWmaterial = "lambert";
shadingNode -asShader $SWmaterial;
The only difference I can see is the use of the brackets when i query the result from the textScrollList, but when I remove the brackets I get this error.
// Error: line 147: Cannot convert data of type string[] to type string. //
Thanks for any help! -DD