PDA

View Full Version : Add channel Speed and Acceleration for selected objects on selected channels


brunodek
07-18-2003, 12:19 PM
Hello,
that's a small mel to create a channel speed and acceleration from any selected channel of any selected node.
Some time it's very usefull.
:beer:

code :
------------------------------------------------------------------------------

// SpAccChannel.mel Add channel Speed and/or Acceleration for selected objects on selected channels
//Bruno Dekeijser 2000 12 11


global proc SpAccChannel()
{
string $channelist[]=`channelBox -q -sma mainChannelBox`;
string $curcha;
string $selectlist[]=`ls -sl`;
string $current;
for ($current in $selectlist)
{
for ($curcha in $channelist)
{
// addAttr Channels Speed
string $chsns = $curcha+"s";
string $chlns = $curcha+"Speed";
string $curchsns = $current+"."+$chsns;
print ("\nadd channels Speed and Acceleration on "+$curchsns);select -cl; select $current;
addAttr -at "float" -ln $chlns -sn $chsns -k 1 $current;
string $expname = ("exp"+$current+$chlns);
string $expadd = "float $valcurcha = `getAttr "+$current+"."+$curcha+"`;\n";
$expadd = $expadd+"float $valcurcha2 = `getAttr -time (frame-1) "+$current+"."+$curcha+"`;\n";
$expadd = $expadd+$curchsns+" = abs($valcurcha - $valcurcha2);";
expression -s ($expadd) -o $current -ae 1 -uc all -n $expname;
// addAttr Channels Acceleration
string $chsna = $curcha+"a";
string $chlna = $curcha+"Acc";
string $curchsna = $current+"."+$chsna;
print (" "+$curchsna+"\n");select -cl; select $current;
addAttr -at "float" -ln $chlna -sn $chsna -k 1 $current;
$expname = ("exp"+$current+$chlna);
$expadd = "float $valcurcha = `getAttr "+$current+"."+$curcha+"`;\n";
$expadd = $expadd+"float $valcurcha1 = `getAttr -time (frame-1) "+$current+"."+$curcha+"`;\n";
$expadd = $expadd+"float $valcurcha2 = `getAttr -time (frame-2) "+$current+"."+$curcha+"`;\n";
$expadd = $expadd+$curchsna+" = ($valcurcha2 - $valcurcha1)-($valcurcha1 - $valcurcha);";
expression -s ($expadd) -o $current -ae 1 -uc all -n $expname;
}
}
}

CGTalk Moderation
01-15-2006, 04:00 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.