Thursday, June 19, 2008

Animate Sequence v.1.0


/*
-------------------------------------------------------------------------------------
\\\\\\\\________________________ANIMATE SEQUENCE v1.0________________________////////
//////// \\\\\\\\
-------------------------------------------------------------------------------------
> Written by dimitris gourdoukis.
> object-e architecture 2008.
-------------------------------------------------------------------------------------
> http://object-e.blogspot.com/
> object.e.architecture@gmail.com
-------------------------------------------------------------------------------------
> v1.0 Last Modified 4/26/08.
> Use and modify at your own risk.
-------------------------------------------------------------------------------------
> Description:
This script animates sequentially the creation of the selected objects by setting
their scale value to 0 and then back to 1. The order of the selection defines the
order of the animation. Start frame value specifies the frame where the animation
begins. Duration value specifies the number of frames after which each new object
is created.
-------------------------------------------------------------------------------------
*/

proc animateSequence (){

//list the selected objects
string $list[] = `ls -sl`;
//get the size of the array
$size = size($list);

int $startFrame = `intSliderGrp -q -v startFrame`;
int $duration = `intSliderGrp -q -v duration`;

//start a loop for each object in the array
for ($i=0; $i<$size; $i++){
string $selObject = $list[$i];
//$dur = 5;
select -r $selObject;
currentTime ($startFrame + $i*$duration);


string $parsex = $selObject + ".scaleX";
string $parsey = $selObject + ".scaleY";
string $parsez = $selObject + ".scaleZ";

setAttr $parsex 0;
setAttr $parsey 0;
setAttr $parsez 0;
setKeyframe $selObject.sx;
setKeyframe $selObject.sy;
setKeyframe $selObject.sz;

currentTime ($startFrame + ($i*$duration) + $duration) ;


setAttr $parsex 1;
setAttr $parsey 1;
setAttr $parsez 1;
setKeyframe $selObject.sx;
setKeyframe $selObject.sy;
setKeyframe $selObject.sz;

}
}

global proc constructAnimWin ()
{
if (`window -exists animateWindow`) {
deleteUI animateWindow;
}


window
-width 400
-height 200
-title "animate sequence"
-sizeable true
animateWindow;

columnLayout;

text -l "";

intSliderGrp -label "start frame"
-field true
-fieldStep 1
-sliderStep 1
-value 0
-fieldMinValue -100 -fieldMaxValue 1000
startFrame;

intSliderGrp -label "duration"
-field true
-value 5
duration;

//create button
button -label "Animate"
-command "animateSequence" buildIt;

setParent ..;

//break
columnLayout;
text -l "";
separator -w 800 -h 4 -backgroundColor 1 0.663 1;
text -l "object-e / dimitris gourdoukis. 2008.";
text -l "http://object-e.blogspot.com/";

showWindow;
}

constructAnimWin;

No comments: