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

Know a keyframe's exact time on timeline

New Here ,
Mar 26, 2024 Mar 26, 2024

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
283
Translate
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
Advocate ,
Mar 26, 2024 Mar 26, 2024

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'
}

 

Translate
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
LATEST

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

Translate
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