View Full Version : Operation +

04 April 2009, 01:34 AM
When I run this
//Change ShapeColor
string $selShape[] = `listRelatives -shapes`;

for ($myObj in $selShape)
setAttr ($myObj + ".overrideEnabled")1;
setAttr ($myObj + ".overrideColor")17;

the ($myObj + ".overrideEnabled") works just fine.
But when I run this.
//Get the arcLen
string $sel[] = `ls-sl`;
string $arcLenNode = `arclen -ch -1 -n ($sel + "curveInfo") $sel`;

I get this error
Illegal operation "+" on data of type string[].

Why does ($myObj + ".overrideEnabled") work in the loop? But it does not work other wise.
I run into this problem a lot when I try to get a specific attribute.

04 April 2009, 03:11 AM
Because (from your example) $myObj is a string, while $sel is a string array. you can only concatenate a string with another string, not a string array (at least in MEL).

string $sel[] = `ls-sl`;

if you just need the first selected object, then just execute it this way:

string $arcLenNode = `arclen -ch -1 -n ($sel[0] + "curveInfo") $sel[0]`;

CGTalk Moderation
04 April 2009, 03:11 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.