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

[Script] Add amount to keyframe velocity?

New Here ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

I know how to change the value of the velocity of a key-frame (setTemporalEaseAtKey), but what if - instead of changing the ENTIRE value - I want to add to the pre-existing one.

The equivalent of xxxx.setValue(xxxx.value + Amount); but for the keyframe velocity.

Thank you!

TOPICS
Scripting

Views

234

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
Enthusiast ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

Well as you say it's the equivalent of grabbing the existing value, adding to it, then setting it. It's just a bit more laborious with something like ease because the KeyFrameEase object is an array (of length 1 to 3 depending on how many dimensions the property is) of both .speed and .influence values.

For example, increasing the in+out speed of the first dimension of the second keyframe on a selected property:

var activeItem = app.project.activeItem;
var selectedProp = activeItem.selectedLayers[0].selectedProperties[0];
var easeIn = selectedProp.keyInTemporalEase(2);
var easeOut = selectedProp.keyOutTemporalEase(2);
easeIn[0].speed = easeIn[0].speed + 10;
easeOut[0].speed = easeOut[0].speed + 10;
selectedProp.setTemporalEaseAtKey(2, easeIn, easeOut);

 

 

 

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
New Here ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

Thank you so much! It works well with the speed!

 

What if I want to apply to the influence? Do I just need to change .speed or .influence? This code doesn't seem to work:

 

var activeItem = app.project.activeItem;
var selectedProp = activeItem.selectedLayers[0].selectedProperties[0];
var easeIn = selectedProp.keyInTemporalEase(2);
var easeOut = selectedProp.keyOutTemporalEase(2);
easeIn[0].influence = easeIn[0].influence + 10;
easeOut[0].influence = easeOut[0].influence + 10;
selectedProp.setTemporalEaseAtKey(2, easeIn, easeOut);

 

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
Enthusiast ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

LATEST

Yeah that is strange. I can't explain why it's working for .speed but not .influence.

It can obviously read the .influence, as evidenced by a line like this:

$.writeln(easeOut[0].influence);

 

And it does seem to work if you create a new KeyframeEase object.

easeOut[0] = new KeyframeEase(easeOut[0].speed, easeOut[0].influence + 10);

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