How to loop a path in After Effects - and still be able to edit it
Path properties don't work with the usual loopOut expression. So we normally use a workaround expression (there are a few out there) but it’ll prevent you from tweaking the path shapes - once a path has an expression on it, you can’t edit the shape without temporarily disabling the expression. Turning it on and off again, over and over, can get annoying.
But. If you use TWO paths - one for your keyframes and one with a looping expression, you can still edit the keyframes whilst it loops!
👆 This is the ideal setup - with the keyframed path in a separate group. Notice how the lower Shape 1 group has no strokes or fills - you can still see the path when you have the layer selected, but it won’t be visible in a preview or render. This is the path that you’d animate with keyframes.
Here's the expression 👇. You apply this to the Shape group that does have strokes or fills. You’ll probably need to amend the first line to reference your keyframed path. You can do that by selecting the part that comes after the = and then dragging the pickwhip on to the keyframed path property.
origPath = content("Shape 1").content("Path 1").path; firstKey = origPath.key(1); dur = origPath.key(origPath.numKeys).time-firstKey.time; t=time-firstKey.time; looptime=Math.abs(t)%dur; if(time<firstKey.time) looptime=dur-looptime; origPath.valueAtTime(firstKey.time+looptime);
This expression will loop a path both in and out. To give credit where it's due, I adapted this from an expression I already had but I don't know who wrote the original. Possibly Paul Conigliaro.
Share this post: