ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Scripting - Keyframes not moving properly.

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
praveen kulk
Scripting - Keyframes not moving properly.
on Mar 17, 2020 at 2:24:21 pm

I am trying to move the selected keyframes of the selected properties with script, but it is moving only first selected property keyframes and not second ones.
Here is my script -
var mComp = app.project.activeItem;
var selecLayers = mComp.selectedLayers;
for (i=0;i=0; k--){
var newKeyValue = seleProp[j].keyValue(seleKeys[k]);
var newKeyTime = seleProp[j].keyTime(seleKeys[k]) + 0.06;
var newKey = seleProp[j].addKey(newKeyTime);
seleProp[j].setValueAtKey(newKey, newKeyValue);
seleProp[j].removeKey(seleKeys[k]);
}
}
}
what Am i doing wrong here?

pbk


Return to posts index

Walter Soyka
Re: Scripting - Keyframes not moving properly.
on Mar 17, 2020 at 5:21:11 pm

1) Is this just a fragment of your entire script? It's not clear to me from this what the i, j and k variables are meant to store.

2) The flow control in your for() loop is incorrect. See here for a quick overview of how the loop should work:
https://www.w3schools.com/js/js_loop_for.asp

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

praveen kulk
Re: Scripting - Keyframes not moving properly.
on Mar 17, 2020 at 6:47:37 pm

example here - if i select some keys in position property and some keys in scale property and execute this script, only position keys will move, scale keys will not.
i represents layer, j represents property and k represents key in for loops.
Its nested for loop - 'keyframe' for loop is inside 'property' for loop which is inside 'layer' for loop.

pbk


Return to posts index


praveen kulk
Re: Scripting - Keyframes not moving properly.
on Mar 17, 2020 at 6:49:24 pm

here is the correct script -

var mComp = app.project.activeItem;
var selecLayers = mComp.selectedLayers;
for (i=0;i=0; k--){
var newKeyValue = seleProp[j].keyValue(seleKeys[k]);
var newKeyTime = seleProp[j].keyTime(seleKeys[k]) + 0.06;
var newKey = seleProp[j].addKey(newKeyTime);
seleProp[j].setValueAtKey(newKey, newKeyValue);
seleProp[j].removeKey(seleKeys[k]);
}
}
}

pbk


Return to posts index

praveen kulk
Re: Scripting - Keyframes not moving properly.
on Mar 17, 2020 at 6:57:32 pm

ok, iam not getting the script to display correctly here, so here it goes -
so here is the screenshot


pbk


Return to posts index

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