PDA

View Full Version : Index range in MEL? Like $a[1:2]? No?


meetar
12-12-2010, 04:55 PM
string $list[] = {"a", "b", "c"};
print($list[0:1]);
// Error: Line 2.14: Syntax error //

Isn't there any way to specify an index range in MEL?
And could a last-index character like "$" be too much too ask? I know negative indices don't work.

This is especially confusing because Maya often returns indices in ranges, especially with faces, vertices, etc.

:shrug:

ginodauri
12-12-2010, 08:01 PM
select -r pPlane2.pnts[0:2];
This is not the same regarding vertices because these are multi attributes.

Solution would be to write your own procedure with for loop in it.

Example:

inputs(array,start,stop)
for($i=start,$j=0;$i<stop;$i++,$j++)
{
$temp[$j]=$array[$i]
}
return $temp

for last element in array maybe like this:

string $array[]={"a","b","c"};
print $array[size($array)-1];

mduvekot
12-12-2010, 08:17 PM
Not really; you could do something like this:


string $list[] = {"a", "b", "c"};
stringArrayRemoveAtIndex(`size $list`-1, $list); print $list;

meetar
12-12-2010, 08:21 PM
That's what I was afraid of... at least now there's a paper trail. Thanks!

pritishd
12-12-2010, 08:31 PM
string $list[] = {"a", "b", "c"};
print($list[0:1]);
// Error: Line 2.14: Syntax error //

Isn't there any way to specify an index range in MEL?
And could a last-index character like "$" be too much too ask? I know negative indices don't work.

This is especially confusing because Maya often returns indices in ranges, especially with faces, vertices, etc.

:shrug:

How about just using a For Loop?

CGTalk Moderation
12-12-2010, 08:31 PM
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.