Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions For through expression

  • For through expression

    Posted by Scott Mcgee on June 20, 2018 at 4:33 pm

    I’ve still not managed to get the hang of these yet.

    Can anyone help me please.

    I have a csv file and 10 lines Max

    I have two columns

    footage(“ColumnOne data.csv”).dataValue([0,0]);
    footage(“ColumnTwo data.csv”).dataValue([1,0]);

    These Two column vary based on how many are in each column
    One time can be

    ColumnOne = 3
    ColumnTwo = 5

    Next time

    ColumnOne = 7
    ColumnTwo = 2

    What I want to do is a for through combined with a try expression.

    for(i = index-1; i <= thisComp.numLayers; I++){
    try{
    //Start using ColumnOne and continue through that column until you reach nothing.
    } catch(e) {
    //Start using ColumnTwo and continue through that column until you reach nothing and stop.
    }
    }

    I’ve done similar things, but I’m struggling to get this to work. So any ideas would be appreciated.

    Scott Mcgee replied 8 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Andrei Popa

    June 21, 2018 at 8:13 am

    the part with footage(“ColumnOne data.csv”).dataValue([0,0]); looks unknown to me. I suppose it s the not-so-new thing with using data in expressions. But i can help you with the script part. You should run another try for the second column. The try/catch tries something and if there is an error catches it and then executes the second part. So you have some code in the second part that throws an error. The try does nothing, because the error is not in the first part. So either use another try, maybe like this
    for(i = index-1; i <= thisComp.numLayers; I++){
    try{
    //Start using ColumnOne and continue through that column until you reach nothing.
    } catch(e) {}
    try{
    //Start using ColumnTwo and continue through that column until you reach nothing and stop.
    }catch(e){}
    }

    Or you could use a while. More elegant and less space for errors. something like while (condition met when column is done) for each column. If the thing you are looking for is the way to navigate through the columns, well, i helped you with nothing ???? But if that is what you were looking for, do tell, i could make a little research and maybe we can get this through.

    Andrei
    My Envato portfolio.

  • Scott Mcgee

    June 22, 2018 at 8:25 am

    I couldn’t get it to work the way you suggested.

    I figured a way to cheat it using the opacity

    I’m going to be expanding this to base itself on comp name as I’ll have a few different version, but I use this in my sourceText

    try{
    footage(“Bruntingthorpe data.csv”).dataValue([1,0]);
    }catch(e){
    “”
    }

    Then this is my opacity for Column One

    x = null;
    for ( i = index+2; i <= thisComp.numLayers; i++){
    try{
    L = thisComp.layer(i)
    if(L.text.sourceText.length < 1 || text.sourceText.length > 1){
    x = 100;
    }
    break;
    }catch(err){
    if(text.sourceText == “”){
    x = 0;
    }else{
    x =100;
    }
    }

    Then the first row item of column two

    x = null;
    for ( i = index+1; i <= thisComp.numLayers; i++){
    try{
    L = thisComp.layer(i)
    if(L.transform.opacity == 100) continue;
    if(L.transform.opacity == 0){
    x = L.transform.position[0];
    }
    break;
    }catch(err){
    }
    }
    [x,value[1]]
    }
    x

    Then everything then follows that item with a basic position expression.

    It’s a messy way of doing it, but it works.

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