Keyframe Updating-ResearchNodes

From scripting
Jump to: navigation, search

This little script shows how to keyframe individual attributes and 
how to force a screen update during script execution.

global proc MoveSomething (string $object, float $x, float $y, float $z)
	setKeyframe -t `currentTime -q` -at tx -v ($x) $object; 
	setKeyframe -t `currentTime -q` -at ty -v ($y) $object;
	setKeyframe -t `currentTime -q` -at tz -v ($z) $object;

// Here would be your program loop:
select -all; delete;

$object = `sphere`;
// Don't forget, $object is now a list

currentTime -e 0 -u 1; // This sets the timeslider with the refresh
setKeyframe -t `currentTime -q` -at sx -v (3) -at sy -v (3) -at sz -v (3)$object;//

for ($i=0;$i<=40; $i++){
    currentTime -e $i -u 1;
    // -OR- refresh();
    MoveSomething($object[0], `rand 1 10`, `rand 1 10`, `rand 1 10`);

setKeyframe -t `currentTime -q` -at sx -v (.2) -at sy -v (.2) -at sz -v (.2) $object;