string $sel[] = `ls -sl`;
string $allDecendants[] = `listRelatives -fullPath -allDescendents $sel`;
string $allObjects[] = stringArrayCatenate($sel, $allDecendants);
float $lastKey = -98989898989;
for ($c in $allObjects){
string $allAttrs[] = `listAnimatable $c`;
for ($attr in $allAttrs){
float $keyLst[] = `keyframe -q -tc $attr`;
if (size($keyLst) > 0){
if ($keyLst[(size($keyLst))-1] > $lastKey)
$lastKey = $keyLst[(size($keyLst))-1];
}
}
}
playbackOptions -min 1 -ast 1;
playbackOptions -aet $lastKey -max $lastKey;
print ("last keyframe is " + $lastKey);
Replies
One of the design goals with Perl's variables for example was to make them visually distinguishable from builtins, reserved words hence why variables used the prefix '$'
The for part is also known as a for each loop.
The script creates a local variable $c and uses it to iterate through the values of $allObjects. Within the { } brackets the $c variable changes on each iteration to the next item of the $allObjects collection.
Hope that explains, personally I find the above code hard to read, to many $ signs and inconsistent ' ' signs. Is this perl in Modo?
I don't like it either.
https://en.wikipedia.org/wiki/Iterator
the same thing in python looks like this: