Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Set keyframe data on multiple layers from a CSV

  • Set keyframe data on multiple layers from a CSV

    Posted by Kevin Hicks on August 17, 2020 at 10:56 pm

    I have a need to create 300 “dots” and have them all start from various positions, then move to different position at the same time. I will be given a spreadsheet with X & Y values for start and end for each “dot.” No other changes – just moving from one point to the next.

    Instead of manually setting the position for each, I was hoping that there was a way that I could use the spread sheet as a CSV to set the different position values. IOW – can I take a 300-line spread sheet and apply each line’s value to a different layer in a comp?

    I’m essentially trying to recreate the movement (just as simple) as you see on the charts in this link: https://nickchk.com/causalgraphs.html

    Thanks for any help!

    Walter Soyka replied 6 years ago 3 Members · 4 Replies
  • 4 Replies
  • Filip Vandueren

    August 18, 2020 at 12:30 pm

    Would the dots need to be created , or are these existing layers in your comp ?

    A script seems better for handling this many layers and data than an expression.
    Unfortunatley, scripts don’t have csv_parsing built in, but there are ways around that.

  • Kevin Hicks

    August 18, 2020 at 12:57 pm

    Yes, the dots would need to be created.

  • Filip Vandueren

    August 18, 2020 at 1:36 pm

    Something like this:

    csv:
    xfrom,yfrom,xto,yto
    476,379,197,475
    362,136,460,71
    491,5,414,317
    427,368,440,435

    for 300 lines

    add the csv to a composition.

    select the csv-layer and then run this script:

    script:

    app.beginUndoGroup("300 dots");
    var comp = app.project.activeItem;
    l = comp.selectedLayers[0];

    var dotSize=[8,8];

    if (l && l.data && l.data.numProperties) {
    numDots = l.data(1).value;

    for (var i=1; i < numDots+1; i++) {
    fromPos = [ l.data(2)(1)(i).value, l.data(2)(2)(i).value];
    toPos = [ l.data(2)(3)(i).value, l.data(2)(4)(i).value];

    sh = comp.layers.addShape();
    el = sh("Contents").addProperty("ADBE Vector Shape - Ellipse");
    el("ADBE Vector Ellipse Size").setValue(dotSize);
    sh("Contents").addProperty("ADBE Vector Graphic - Fill");

    sh.transform.position.setValuesAtTimes([1,2],[fromPos, toPos]);

    sh.name = "dot "+i;
    }

    } else {
    alert("select .csv layer");
    }

    app.endUndoGroup();

    -> as manu shapelayers as lines in the csv with keyframes at 1second and 2 seconds

  • Walter Soyka

    August 18, 2020 at 1:41 pm

    If you don’t mind creating the shape layers, you can set this up very easily with expressions.

    Here’s a proof of concept. The data:

    The animation:

    The AEP:
    14275_xymovecsv.zip.zip

    The magic:
    1. After Effects supports CSV data directly now, so we import our CSV file into our project.

    2. We create a shape layer and use a couple expressions that pull position and color data from the CSV “footage” source into position and color properties. By using the layer’s index number to reference rows in the data table, we make it so we can duplicate the shape layer over and over, and each new layer will refer to the next data point in the table. We just have to be careful to make the right number of layers. (This set of expressions does not do error-checking, but we could write that in.)

    3. We use a single slider on the footage layer to drive all the animation, for easier style and maintenance.

    Let me know if you have any questions!

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

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