Forums › Adobe After Effects Expressions › How can I figure out the legnth of a path.
-
How can I figure out the legnth of a path.
-
Chris Scalzo
March 16, 2015 at 4:36 pmThe problem I’m having is I’m animating a stroke on with trim paths (which is measured in percentage of completion), and have a text layer writing it on with the path options. The First margin property is measured by length of the path. I plugged in a slider temporarily to adjust this value to re synchronize them after moving the path around. I would much prefer to somehow read the length of the path with another expression so it stays lined up as I adjust the path.
-
Dan Ebberts
March 16, 2015 at 5:44 pmI’m not sure if this helps, but it’s the only thing I can think of. If you copy the path and paste it into the position property of a null, the null will trace out the path at a constant speed over a two second period. So if you have a slider controlling the percentage, you can convert that to pixels traveled with something like this:
pct = effect(“Slider Control”)(“Slider”)/100;
thisComp.layer(“Null 1”).position.speedAtTime(0)*2*pct;Dan
-
Chris Scalzo
March 16, 2015 at 6:29 pmThank you for the quick response. I spend around two hours searching for a quick solution. What I have now would probably be easier to manipulate for my current needs. I saw a response you made on paths to someone else stating there is little you can read with expressions on a path. I am running 2014.1.1 and was hoping this would have been updated in 2014.1.2 like the text bounds thing. Anyway, thanks again. I have much respect for your content on creativecow. 🙂
-
Charlie Leroy
March 17, 2015 at 3:50 pmHello Chris,
If I understood correctly you have your stroke going from 0% to 100% and the text layer is following the “moving tip” of the stroke. is that correct?if it is, then you can do this;
you know the First margin starts and the first margin finishthis should make your text starts and finish at the same time as the stroke appears ( if both the path and the stroke are the same obviously)
on the First margin value
//initial margin value
var x=1641;
//final margin value
var y= 3086;
//the End trim percentage
var z= thisComp.layer("Shape Layer 1").content("Trim Paths 1").end;
//cross product
value =z*(y-x)/100+xhope it helps.
Log in to reply.