FORUMS: list search recent posts

Moving existing keyframes with a .jsx-file

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Martin Bollerup
Moving existing keyframes with a .jsx-file
on Nov 22, 2012 at 3:48:36 pm

Hello fellow coders,

Here's an example:

I've got a layer with two keyframes: in the beginning there's one with opacity 0 then after 1 sec there's one with opacity 100 with some custom easing. I would like to move the both keyframes so that they start 3 seconds.

I can select the keyframes with the code below, but how do I move it? I could add another keyframe with the same values but then any easing done by the designers would have to be copied as well...

best regards,
Martin

{
function findComp(compName)
{
var proj = app.project;
for( var i = 1 ; i &lt;= proj.numItems; i++) {
var item = proj.item(i);
switch (item.typeName) {
case 'Composition':
if (item.name == compName) {
return item;
}
break;
}
}
}
if( ! app.project ) {
alert("no project");
} else {
// Find the mainComp
mainComp = new Object(findComp("MoveKeyframes"));
// Find layer
var layer = mainComp.layer("Layer");
// Find property
var opacityProperty = layer.property("Opacity");
// Select keys
opacityProperty.setSelectedAtKey(1, true );
opacityProperty.setSelectedAtKey(2, true );
var selectedKeys = opacityProperty.selectedKeys;

// Move selected keys
// ??????????
}
}


Return to posts index

Dan Ebberts
Re: Moving existing keyframes with a .jsx-file
on Nov 22, 2012 at 4:32:13 pm

Unfortunately, as far as I know, you can't move a keyframe with scripting. You have to create a new one, copy each of the attributes (including easing), then delete the original keyframe.

Dan



Return to posts index

Martin Bollerup
Re: Moving existing keyframes with a .jsx-file
on Nov 22, 2012 at 9:46:41 pm

Hmm thought so :-)

I tried to fool around with the PropertyGroup object but couldn't find a way to get anything but errors. Isn't there a way to copy the easing between to keyframes (all handles on the curve etc.) and add them to another two?

Thanks,
Martin


Return to posts index


Xavier Gomez
Re: Moving existing keyframes with a .jsx-file
on Nov 24, 2012 at 11:24:12 am

There already exists a script that allows to move nearly everything (including keyframes) on a layer's timeline:

rd_scooter: link (by Jeff Almasol).

If what you want is to write your own script, then you can look there to see how it works.

Xavier


Return to posts index

Martin Bollerup
Re: Moving existing keyframes with a .jsx-file
on Nov 26, 2012 at 10:21:19 am

Thank you so much Xavier - that just made my monday start like a charm!!!

Have a great day,
Martin


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]