Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Value range instead of creating each individual numbers

  • Value range instead of creating each individual numbers

    Posted by Jo Craft on February 26, 2023 at 12:14 am

    Hi all!

    I am making a path based on data. I’ll have close to a 1000 X and Y points to place on that path once I get the full set. I am using the following expression to create said points using a JSON file with X and Y values. And I will eventually use Vegas or Trim Path or something of that nature to animate the path.

    createPath(points = [[thisComp.layer("JSON")("Data")("Outline")("dataOutline 0")("X"),thisComp.layer("JSON")("Data")("Outline")("dataOutline 0")("Y")], 
    [thisComp.layer("JSON")("Data")("Outline")("dataOutline 1")("X"),thisComp.layer("JSON")("Data")("Outline")("dataOutline 1")("Y")], 
    [thisComp.layer("JSON")("Data")("Outline")("dataOutline 2")("X"),thisComp.layer("JSON")("Data")("Outline")("dataOutline 2")("Y")], 
    [thisComp.layer("JSON")("Data")("Outline")("dataOutline 3")("X"),thisComp.layer("JSON")("Data")("Outline")("dataOutline 3")("Y")], [ETC...] inTangents = [], outTangents = [], isClosed = false)

    Now, is there a way to achieve that without having to create one line for each point with a value range or something of that nature? I have found a way to generate the 1000 lines I would need but I figured there might be a cleaner and probably less taxing on AE way to achieve it?

    Or is there a totally different / simpler way you would go about this?

    Thank you so much!

    Jo Craft replied 3 years, 5 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    February 26, 2023 at 12:27 am

    Can you post a chunk of your JSON file?

  • Jo Craft

    February 26, 2023 at 12:43 am

    Sure can, here is an extract, and it will look like this another 1000 times.

    
    

    {

    "YEAR": 2021, "MONTH": 1, "DAY": 6, "HOUR": 16, "MINUTE": 32, "X": 632, "Y": 643 },
    { "YEAR": 2021, "MONTH": 1, "DAY": 6, "HOUR": 17, "MINUTE": 3, "X": 625, "Y": 642 },
  • Dan Ebberts

    February 26, 2023 at 2:04 am

    I don’t know how efficient it will be, but you could tidy things up a bit like this:

    p = [];
    prop = thisComp.layer("JSON")("Data")("Outline");
    n = prop.numProperties;
    for (i = 1; i <= n; i++){
    x = prop(i)("X");
    y = prop(i)("Y");
    p.push([x,y]);
    }
    createPath(p,[],[],false)
  • Jo Craft

    February 27, 2023 at 5:54 pm

    Dan, you are a the best. It works, and it’s much more efficient than the method I was using. Thank you so much. 🙏

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