Skip to main content
StefanStehlik
Inspiring
June 14, 2022
Answered

Filter out selected keyframes from one property

  • June 14, 2022
  • 1 reply
  • 699 views

Hi, everyone!

Is there a way to filter out selected keyframes from one property, like position or anchor point and change keys values? Also how do I check if the selected layers are part of these properties?
I would like to set the position of the anchor point to the selected keyframes.

Thank for answers 🙂

This topic has been closed for replies.
Correct answer Dan Ebberts

Thanks so much for the detail info Dan. Would it be also possible to assign new keyframes to position property at same time as selected keyframes from anchor point, without changing the value of position parameters, just add keyframes at same time as anchor point keyframes.


Something like this, I think:

var myLayer = app.project.activeItem.layer(1);
var myAP = myLayer.property("Anchor Point");
var myPos = myLayer.property("Position");
var myKeys = myAP.selectedKeys;
for (var i = 0; i < myKeys.length; i++){
	myPos.addKey(myAP.keyTime(myKeys[i]));
}

1 reply

Dan Ebberts
Community Expert
Community Expert
June 14, 2022

What do you mean by "filter out"? For a given property, scripting can detect which keyframes are selected, but it's not clear what you want to happen after that.

StefanStehlik
Inspiring
June 14, 2022

Thank you Dan for your response. I want to isolate selected keyframes that are part of a certain property like position or anchor point and perform actions on these keyframes, like setValueAtKey.

Dan Ebberts
Community Expert
Community Expert
June 14, 2022

Here's a simple example that will set selected position keyframes (for layer 1) to [0,0]:

var myLayer = app.project.activeItem.layer(1);
var myProp = myLayer.property("Position");
var myKeys = myProp.selectedKeys;
for (var i = 0; i < myKeys.length; i++){
	myProp.setValueAtKey(myKeys[i],[0,0]);
}