View Full Version : Is there a MEL script that does this...

09 September 2005, 07:56 PM
I'm an animator and in an effort to improve my workflow/quality I'm going down the path of only keying those things/values which have changed instead of just hitting the S key. But, I hate having to go up the channel box>right click on the attribute> then scroll down and hit key selected. Is there a script that I can map to the S key (or any shortcut) that will only key those attributes that have changed? So say I rotate the hand of a character in Y it will only set a key for Y-rotation and not X & Z.

Learning MEL is on my long list of things to learn how to do so I can't do it on my own right now. It seems like on the surface this would be something relatively simple to do. No specific naming conventions involved. Just something that does this to whatever item happens to be selected.

If anyone has any ideas, or wants to do this I'd be very gratefull. Or am I wrong and a script for this already exists. Thanks.

09 September 2005, 08:10 PM
Can't you just use the "Auto Key" feature? This only sets a key on any attribute/value that you change. This of course will set a key for any changes, so say you rotate the hand control on X and Z, and then decide you don't need the X rotation, you will either have to undo back to before you changed the values, or manually remove the un-needed key.

Just a thought.

09 September 2005, 02:15 AM
auto key does sound like what you want...
but if not, try this.. its just keys any channels that already have keys, on the selected objetcs ...

CODE]string $sel[] = `ls -sl`;
string $attrList[];
for ($current in $sel)
$attrList = `listAttr -k $current`;
for ($attr in $attrList)
int $keyCount = `keyframe -at $attr-query -kc $current`;
if ($keyCount > 0)
setKeyframe -at $attr $current;

09 September 2005, 10:59 AM
here's a script i can't live (animate) without; it's not mine, i found it once, i believe in the days when highend3d was still a site, where one could search for usefull stuff and FIND SOME, too! (don't you just hate the new site???)
anyways, here's the code, with credits 'n' all, HYL:

// H2O Entertainment Corporation
// Calgary, Canada

// This script was inspired through many frustrating hours of manual
// keyframing within SoftImage|3D.

// Sets a keyframe for all "active" channels in the selected objects.
// An "active" channel, in this context, is a channel for which keyframes
// have been set. Such channels highlight in green in the Channel
// Box.
// I want such a function because I often need to quickly set, copy or
// terminate a rest pose for a character at a given frame. This
// requires an explicit keyframe on every single animated channel.
// In this case, I do not want to create any additional animated
// channels; if a channel has no fcurve, I don't want one created.
// I could, arguably, use Edit->Delete By Type->Static Channels
// after the fact. However, there is, arguably, a chance that I just
// may have a "static" channel that I'd want to keep.

// Select one or more objects. Call setKeyOnActiveChannels(). Done.
// Easy.
// 36

global proc setKeyOnActiveChannels()
string $targets[] ;
$targets = `listAnimatable` ;
string $target ;
string $token[] ;
int $keys, $tokens, $newKeys = 0 ;

for ( $target in $targets )
$keys = `keyframe -q -kc $target` ;
if ( $keys > 0 )

$tokens = `tokenize $target "." $token`;

if ( $tokens > 1 )
$newKeys += `setKeyframe -at $token[1] $token[0]`;


print ( "Set " + $newKeys + " keys.n" );

Robert Bateman
09 September 2005, 01:56 PM
there is a much easier way to do this. above the channels box is a little menu called "Channels". select channel control from tha menu, then move the attributes out of the channel box that you don't want keyed. Pressing 's' will then only set the keys that are currently in the channel box.

to only set keys for things that have changed, you want to use autokey (window->settings/preferences) then goto the animation options and set "key modified attributes".... (and yes, autokey sounds like it's exactly what he wants...)

oh, and about highend. We had to perform an overhaul since so many of the scripts and plugins form yester-year were out no longer compatible with the latest sofware, or had simply been superceeded by better features in the packages. To help us track this better we decided to overhaul the site so that the plugins and scripts could be maintained in a much easier way.

We've been in the process of doing this for over a year, and it's been a huge undertaking by a large number of people (all of whom are kind enough to give up their spare time to improving the site). If you have comments regarding the site, you could always be kind enough to direct those at myself or any other preson involved in maintaing highend3d - we'd actually welcome feedback for what needs to be improved. (and we are still updating the content so would welcome any additional submissions of scripts/plugins/shaders/tutorials etc).

09 September 2005, 08:31 PM
there is a much easier way to do this....

well thats a matter of opinion.. one not shared here... but each to their own...

highend rocks ;)

here's a script i can't live (animate) without...;

isnt that just a long version of my script ;^P


CGTalk Moderation
09 September 2005, 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.