• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Filter out selected keyframes from one property

Explorer ,
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

241

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

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

 

Votes

Translate

Translate
Community Expert , 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);
	}
}

Votes

Translate

Translate
Community Expert , 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]));
}

Votes

Translate

Translate
Community Expert ,
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.

Votes

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
Explorer ,
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.

Votes

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

 

Votes

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
Explorer ,
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.

Votes

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
Community Expert ,
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);
	}
}

Votes

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
Explorer ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Thank you

Votes

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
Explorer ,
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.

Votes

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

Votes

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