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?
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
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'
}
Copy link to clipboard
Copied
Thank you very much! I'lk try it out to see if it works!