ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Finding the trim path end point across multiple paths

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Daniel Greenup
Finding the trim path end point across multiple paths
on Mar 12, 2020 at 12:54:26 am

Hi,

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?

Daniel


Return to posts index

Alex Printz
Re: Finding the trim path end point across multiple paths
on Mar 12, 2020 at 9:14:58 pm

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.

Alex Printz
Mograph Designer


Return to posts index

Daniel Greenup
Re: Finding the trim path end point across multiple paths
on Mar 16, 2020 at 4:31:36 am

Thanks Alex, this is very helpful.

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'.

pathIndex = thisProperty.propertyGroup(3).propertyIndex;
totalPaths = content.numProperties;
trimPercent = effect("Percent")("Slider");
(effect("Percent")("Slider")*totalPaths) - ((pathIndex-1)*100);


//Add this Expression to the position of the object following the path.

totalPercent = thisComp.layer("Lines").effect("Percent")("Slider");
shapeLayer = thisComp.layer("Lines");
totalPaths = shapeLayer.content.numProperties;
currentPathIndex = Math.ceil(totalPercent*(totalPaths/100));

if((currentPathIndex == 0) || (currentPathIndex > totalPaths)){
[-1000,-1000];//position when totalPercent is 0 or 100.
}else{
currentPath = shapeLayer.content(currentPathIndex).content(1).path
currentPathOffset = shapeLayer.content(currentPathIndex).transform.position
pathPercent = (totalPercent*totalPaths) - (currentPathIndex*100) + 100;
currentPath.pointOnPath(pathPercent/100,time) + currentPathOffset;
}


Return to posts index


Alex Printz
Re: Finding the trim path end point across multiple paths
on Mar 17, 2020 at 6:24:45 pm

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.

Alex Printz
Mograph Designer


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]