Copy link to clipboard
Copied
Hello to all!
First of all, just want to apologize for my basic English. I will try to explain as clearly as I can.
I have a complex animation layer, which is precompose in another comp which I want to run this animation with markers. If the animation is comprised of two key frames is no problem. You can control the animation of a number of ways, such as using valueAtTime() or linear() ease() function.But when more than two keyframes need to allocate between the two markers is not so easy problem to solve. I tried to change a little Dan Ebberts'(by the way, thanks to him for all!) expression, but still did not work.
n = 0;
m = thisComp.marker;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}
if (n==1){
mStart = m.key(n).time
mDelta = ((m.key(n+1).time - mStart)/numKeys)
for(i = 1; i <= numKeys-1; i++){
kVal1 = valueAtTime(key(i).time)
kVal2 = valueAtTime(key(i+1).time)
linear(time, mStart+(mDelta*i), mStart+(mDelta*(i+1)), kVal1, kVal2);
}
}else{0
}
Image for illustration

If anyone can find a desire to understand problemme guide me in the right direction. Thanks in advance.
I think you just need to remap the time, so this should be close:
m = thisComp.marker;
if (m.numKeys > 1 && numKeys > 1){
t1m = m.key(1).time;
t2m = m.key(2).time;
t1k = key(1).time;
t2k = key(numKeys).time;
t = linear(time,t1m,t2m,t1k,t2k);
valueAtTime(t)
}else{
value
}
Dan
Copy link to clipboard
Copied
Well, frankly: Why bother? Simply split the layer and keyframe it manually. Your screenshot doesn'tr show anything that would rationally explain why expressions should even be necessary.
Mylenium
Copy link to clipboard
Copied
Hi Mylenium!
The reason due to which I am forced to use an expression that I do not the final product, and that sort of designer to create operational schedules for local TV. I'm trying to achieve this level of automation in which not even a dedicated AfterEffect person can easily assemble ready to release a product.
the picture above was just for clarity, here's this from the live project
Copy link to clipboard
Copied
I think you just need to remap the time, so this should be close:
m = thisComp.marker;
if (m.numKeys > 1 && numKeys > 1){
t1m = m.key(1).time;
t2m = m.key(2).time;
t1k = key(1).time;
t2k = key(numKeys).time;
t = linear(time,t1m,t2m,t1k,t2k);
valueAtTime(t)
}else{
value
}
Dan
Copy link to clipboard
Copied
Hi Dan! I am very glad that you have responded. It looks like everything is working just fine. I'm like extremely under complicated the task itself))) As always beautiful and elegant code! Thank you again!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more