Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trying to move an object’s position through a dataset of points with an expression

  • Trying to move an object’s position through a dataset of points with an expression

    Posted by Gregor Knell on April 29, 2013 at 1:15 am

    Hey all,
    I have a data set of around 500 X,Y points that I’d like an object to jump to in succession. I’d like the object to sit at each spot for roughly three frames and then move on.

    Is there a simple way to do this using an Expression on the Position of the object?

    I’ve been scouring the internet but I’m new to expressions and have a feeling I’m searching down the wrong rabbit hole.

    My guess is there’s a bit of code that could be inserted between each position using TextWrangler or something like it that would say something like:
    Go here [first position] for 3 frames.
    Then go here [second position] for 3 frames.
    And then just repeat that code all the way through?
    I might be way way off on this though.

    Here are the first five positions if that helps:
    172,164
    576,412
    340,668
    896,332
    824,832

    Also, The Comp size is 1920×1080.

    Thank you so much in advance for any help or advice you could give me!
    All the best,
    Gregor

    Snorre Hjelseth replied 11 years, 4 months ago 5 Members · 7 Replies
  • 7 Replies
  • Todd Kopriva

    April 29, 2013 at 1:49 am

    I’d set up all of the keyframe information in a spreadsheet and then just paste it in.

    See this page for details.

    ———————————————————————————————————
    Todd Kopriva, Adobe Systems Incorporated
    After Effects quality engineering
    After Effects team blog
    ———————————————————————————————————

  • Dan Ebberts

    April 29, 2013 at 3:54 am

    It could get a little ugly with 500 points, but something like this should work:

    data = [[172,164],[576,412],[340,668],[896,332],[824,832]];
    holdFrames = 3;
    idx = Math.min(Math.floor(timeToFrames(time-inPoint)/holdFrames),data.length-1);
    data[idx]

    Dan

  • Ryan Lewis

    May 1, 2013 at 8:41 pm

    Going off of what Dan said, if you could get the points into CSV or some other regularly-parseable format, just regex them (or simple find/replace commas with bracket pairs) into the aforementioned data format.

  • Gregor Knell

    May 2, 2013 at 11:10 pm

    Dan,
    Thanks so much for this!
    Works like a charm!
    Best,
    Gregor

  • Snorre Hjelseth

    January 8, 2015 at 5:11 pm

    Great! Just what i needed! Do you know how to animate the object between etch position?

  • Dan Ebberts

    January 8, 2015 at 6:02 pm

    Like this maybe:


    data = [[172,164],[576,412],[340,668],[896,332],[824,832]];
    holdFrames = 3;
    moveFrames = 15;
    n = Math.floor(timeToFrames(time-inPoint)/(holdFrames+moveFrames));
    if (n < data.length - 1){
    f = timeToFrames(time-inPoint)%(holdFrames+moveFrames);
    if (f < holdFrames){
    data[n]
    }else{
    ease(f,holdFrames,holdFrames+moveFrames,data[n],data[n+1]);
    }
    }else
    data[data.length-1]

    Dan

  • Snorre Hjelseth

    January 8, 2015 at 6:22 pm

    Thank you so much Dan! You saved my day! I just started using expression in AF so this is a new area for me. I will use it to create an animated graph that changes values over time based on data from excel. Great work! Thanks again!

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