Hey Dan,
I took your code and tried to take it a step further for what I’m looking to do but ran into an issue.
I’m trying to have a number of time remapped layers responding to multiple keyframes on the same null object. I’ve condensed 30 minutes of keyframes down into 5 minutes so there’s a lot of keyframes between frames.
This gets a bit confusing but within each frame, I’d like to sequentially send the keyframes to the time remapped layers. I hope that makes sense? Seeing what I’m doing in the code might help more.
The code works sometimes but then, regardless of where I am in the composition, I get this warning: Bad method arguments: This property has no keyframe numbered 8072, expression disabled. Error occurred at line 13.
(the null object has 8071 keyframes)
I’ve marked the things that I’ve added to you code with what I think they do based on my tests.
Any advice or strategy on how to approach this would be greatly appreciated.
All the best,
Gregor
p = comp("12").layer("Null 1").transform.position;
n = 0
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
}
d = comp("Bulk").layer(index).index; // Current Layer index number.
v = (n+d-1); // Next keyframe index number to effect.
c = p.nearestKey(time).time; // Time of current keyframe.
n = p.key(v).time; // Time of next keyframe.
if ((n-c) < (1/23.976)){ // If the time between the current keyframe and the next one is less then 1 frame (1/23.976)...
t = time - p.key(v).time;
Math.min(t,framesToTime(5))
} else {
framesToTime(5);
}