Filter out selected keyframes from one property

New Here ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

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 🙂

TOPICS
How to , Resources , Scripting

Views

68

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Adobe Community Professional , Jun 14, 2022 Jun 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]);
}

 

Likes

Translate

Translate
Adobe Community Professional , Jun 14, 2022 Jun 14, 2022

Something like this should work:

var myLayer = app.project.activeItem.layer(1);
var myProp = myLayer.property("Position");
if (myProp.numKeys > 0){
	for (var i = 1; i <= myProp.numKeys; i++){
		myProp.setSelectedAtKey(i, true);
	}
}

Likes

Translate

Translate
Adobe Community Professional , Jun 15, 2022 Jun 15, 2022

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]));
}

Likes

Translate

Translate
Adobe Community Professional ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

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]);
}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

Hey Dan, thank you, this works perfectly. I'm still learning this language.
I'm also trying to understand how to check if there is a keyframe in a property, and if there is one, I would like to select all the keyframes in the property.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

Something like this should work:

var myLayer = app.project.activeItem.layer(1);
var myProp = myLayer.property("Position");
if (myProp.numKeys > 0){
	for (var i = 1; i <= myProp.numKeys; i++){
		myProp.setSelectedAtKey(i, true);
	}
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Thank you

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

LATEST

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]));
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines