Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Path To Position

  • Path To Position

  • Jamie Bradshaw

    April 22, 2009 at 9:54 am

    Hi all.

    Is there any way that you can use an expression to take a Path and a percentage along it and covert it to an XY position?

    Thanks,
    Jamie

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Kevin Camp

    April 22, 2009 at 4:07 pm

    there probably is a way to have an expression do it, but you should be able to select your mask path (hit ‘mm’ on the keyboard, select the ‘mask path’ property), copy it, then select you position property and paste the path into the position.

    you should get as many keyframes as you have points on the mask, with the first and last keyframes being locke to time and any in between being roving. so as you drag the first or last keyframes the roving keyframes will distribute accordingly…

    does that help you out…?

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Jamie Bradshaw

    April 22, 2009 at 4:34 pm

    Thanks Kevin.

    Yeah I already am using that technique, but was really after an expression so that I can make the project a lot easier for other people to pick up and use.

    Thanks,
    Jamie

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • ben rollason

    April 22, 2009 at 11:12 pm

    I don’t think you can pull the mask point values straight out of a mask path. I’ve never heard of it anyway.

    What you can do though is copy the mask path, paste it into the position attribute of a null layer (or any layer with visibility turned off). It doesn’t matter where the keyframes fall in time.

    Then add an expression slider to the layer you want to move along the path. I called my slider “percentage”, then paste the following code into the position attribute of the same layer.


    tPath = thisComp.layer("null").transform.position; //change this to the null layer you just created!
    tLastFrame = tPath.key(tPath.numKeys).time;//get the time of the last keyframe
    tFirstFrame = tPath.key(1).time; //get the time of the first keyframe

    tPercentage = effect("percentage")("Slider")/100; //read in the value from the percentage slider
    //the next line converts that percentage into a point in time between the first and last keyframe.
    tPercentageAsATime = (tPercentage*(tLastFrame-tFirstFrame)) + tFirstFrame;

    myPos = tPath.valueAtTime(tPercentageAsATime); //read the position at that point in time and put it into this layer's current position. Hey presto!

    Now you can have multiple layers all referencing the same path, but moving along it at different times, courtesy of their percentage slider.

    Hope that helps.

    -Ben.

    http://www.benrollason.com

  • Jamie Bradshaw

    April 23, 2009 at 9:43 am

    Cheers Ben. This looks like it might work.

    Thanks!

    Jamie

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Kim Huston

    June 23, 2009 at 8:26 pm

    I used the copy mask shape properties and past into the position property technique, but it made the path much larger upon pasting than the path I actually drew. Is there a way to make it either not do that from the start, or to shrink the position keyframes down to a smaller version of the path?

    The path is a spiral and I want the spiral to be tighter. Right now the spiral goes way off the composition screen.

  • Alberto Cadena

    May 4, 2020 at 10:07 am

    Ben!
    Thanks!
    Love ya man!

Viewing 1 - 7 of 7 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy