Skip to main content
Participant
April 25, 2023
Answered

Position Expression

  • April 25, 2023
  • 1 reply
  • 561 views

Hello all, My issues is, i have one shape layer, which is moving from left to right and vice versa. so now if i use expression loopout("Cycle"); , it will be looping for the infinite times. but the thing is want to loop this for only 8-10 itterations times. so how can i achieve this in After effects. 

If you say to do this "loopOut("cycle",8)" , then its now working at all, it is looping for infinite number of times.

 

Thank you.

This topic has been closed for replies.
Correct answer Rick Gerard

Adding a number after you define the type of loop tells the number of keyframes you want to use. If there are eight keyframes and you use loopOut("Cycle", 2), the loop will use the first and the last 2 keyframes.

 

In order to get a loop to stop, you need the define the number of keyframes, the time of the last keyframe minus the layer's in-point, and the number of loops you want, then throw in an if statement that runs the loop for the number of times you want it to run until the end time of the loop. 

 

Try this:

 

nKeys = 3;
nLoops = 8;
st = time - inPoint; 
lKey = key(nKeys).time - inPoint;
nTimes = nLoops * lKey;
if (st < nTimes){
	loopOut("cycle");
}
else{
	key(nKeys).value
}

 

 

1 reply

Rick GerardCommunity ExpertCorrect answer
Community Expert
April 25, 2023

Adding a number after you define the type of loop tells the number of keyframes you want to use. If there are eight keyframes and you use loopOut("Cycle", 2), the loop will use the first and the last 2 keyframes.

 

In order to get a loop to stop, you need the define the number of keyframes, the time of the last keyframe minus the layer's in-point, and the number of loops you want, then throw in an if statement that runs the loop for the number of times you want it to run until the end time of the loop. 

 

Try this:

 

nKeys = 3;
nLoops = 8;
st = time - inPoint; 
lKey = key(nKeys).time - inPoint;
nTimes = nLoops * lKey;
if (st < nTimes){
	loopOut("cycle");
}
else{
	key(nKeys).value
}

 

 

Participant
April 25, 2023

Thankyou so much, had been searching for an hour. Finally.