Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects ExtendScript function question

  • ExtendScript function question

    Posted by Huntington Carpenter on January 7, 2020 at 12:50 am

    Hey all just a quick question to try and get some help. I have a function running to duplicate a layer in extendscript. It dupes the layer and adds a number on the end sequentially which is perfect. The part that is stumping me is I then need it to also add that number sequentially to the expression that is on that layer. I know that it is reading the expression correctly because I get it on every dupe it just doesn’t add the number to the expression. Any help appreciated, having a rough time learning this.
    exa below
    —————————-
    var comp = newComp2;
    var layer = comp.layer(“LINE “);
    var yPos = layer.property(“ADBE Transform Group”).property(“ADBE Position_1”);
    var exp = yPos.expression = “test “;

    createLines(comp, layer, parseInt(titleEditText.text), yPos, parseInt(titleEditText.text));
    newComp2.layer(“LINE “).remove();

    function createLines(comp, layer, lines, yPos, exp){
    var dLayer;
    for(var i = 1; i <= lines; i++){
    dLayer = layer.duplicate();
    dLayer.name = “LINE “+i.toString();

    }

    }

    Huntington Carpenter replied 6 years, 4 months ago 1 Member · 1 Reply
  • 1 Reply
  • Huntington Carpenter

    January 7, 2020 at 3:54 am

    I figured it out if anyone was curious ☺

    var comp = newComp2;
    var layer = comp.layer(“LINE “);
    var yPos = layer.property(“ADBE Transform Group”).property(“ADBE Position_1”);
    var exp = yPos.expression = “””thisComp.layer(“line control”).effect(“Slider Control”)(“Slider”)+thisComp.layer(“minor adjustment”).effect(“Slider Control”)(“Slider”)-1+”””;

    createLines(comp, layer, parseInt(titleEditText.text), yPos, parseInt(titleEditText.text));
    newComp2.layer(“LINE “).remove();

    function createLines(comp, layer, lines, yPos, exp){
    var dLayer;
    for(var i = 1; i <= lines; i++){
    exp = yPos.expression = “””thisComp.layer(“line control”).effect(“Slider Control”)(“Slider”)+thisComp.layer(“minor adjustment”).effect(“Slider Control”)(“Slider”)-1+”””+i.toString();
    dLayer = layer.duplicate();
    dLayer.name = “LINE “+i.toString();

    }

    }

    }

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