I am looking for a way to find the trim path end position when using multiple paths. For example I want to be able to position an image of a pen to travel along one path and then jump to the next paths as I use trim path to reveal an image. Like what you see in whiteboard animations. A bit like path.pointOnPath but for multiple paths together. Is there someway to do this? Like referencing an array of paths?
You’re going to need to do a few things; if i was going to do this I would:
1. Get the target image to follow the point and rotation (if desired) on a single path with pointOnPath/normalOnPath and toWorld functions/toWorldVec from a selected point. Dan has great writeups on that already.
Then you’re going to need to make a global ‘trim’ slider that can go from 0-(numPaths*100), and then for each of your shape layer paths you’re going to need to set their trims to go from ((pathIndex-1)*100 – pathIndex*100) so that sliding the global slider will draw each path appropriately.
Then add a switch function prior to the image’s pointOnPath section of the script, and make the case function look for which trim path is ‘active’ in the global ‘trim’ slider, and then swap out the target Layer based on whichever is the target.
Sliding through the global ‘trim’ slider should now draw through all of the layers. If you need to do blank sections, simply don’t add a stroke for another layer to bridge two visible layers.
The only problem I see is that the timing for each stroke is exactly the same. For example, if I am drawing a lower case i, the dot on top will take just as long to reveal as the line beneath it. For what I am using it for thought, I don’t think it will be noticeable. Here is the expressions incase anyone else is interested.
//Add an expression slider on the shape layer called "Percent"
//Add this Expression for every trim paths 'End'.
Simply keyframe each 0-100 and spread the keys as necessary.
If you really want to measure the length between the different strokes, you’re going to have to build a loop that measures each length, compares them, and then trims them. I don’t suggest doing it that way.