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

Know a keyframe's exact time on timeline

New Here ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

I want to know if there's an expression to know the time at which a keyframe is positioned on a timeline (i.e. if a keyframe is at second 2:00, I want an expression telling me that the keyframe's time is 2:00 or its corresponding frame).

 

Can anybody help me, please?

TOPICS
Expressions

Views

59

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
Engaged ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

Somthing like this:

 

Get Key Index From Time/Frame:

 

target = thisComp.layer("Shape Layer 1").position;
frame = 60;
// or 
// frame = timeToFrames(2);
result = 'not found';
for (i = 1; i <= target.numKeys; i++) {
  if (timeToFrames(target.key(i).time) == frame) {
    result = 'key: ' + i;
    break
  }
}
result

 

screenshot.png

 

Get Key Time From From Key Index:

target = thisComp.layer("Shape Layer 1").position;
if (target.numKeys) {
  numKey = 2;
  target.key(numKey).time + 's';
  // or
  // timeToFrames(target.key(numKey).time) +' frames';
} else {
  'no keyframe'
}

 

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 ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

LATEST

Thank you very much! I'lk try it out to see if it works!

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