Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions get name from effect controls and add them to expression

  • get name from effect controls and add them to expression

    Posted by Sam Catt on May 16, 2018 at 10:05 pm

    So i’ve been pondering on this for a while now.

    I want to select a layer and, in an AE UI input text field specify how many iterations of an effect control I want: I.E

    Target 1
    Target 2
    Target 3
    Target 4
    Target 5

    etc etc. I have this working perfectly. Now I want to be able to take the effect control names and add them to the layers expression

    I.E:

    – start of expression here –
    target 1
    target 2
    target 3
    target 4
    target 5
    – end of expression here –

    my guess, is I would have to create an array? and then link back to the arrays name in the expression = “”;

    Though I have no idea how to actually go about doing that exact thing. My current code is below, ignore the “5” in for (var n = 0; n < 5; n++){ it’s a dummy for selecting 5 in te UI text box

    app.beginUndoGroup("Dynamic Parenting");

    var myComp = app.project.activeItem;

    if (myComp == null || !(myComp instanceof CompItem)){
    alert(errorNoCompSelected);
    } else {
    var selectedLayers = myComp.selectedLayers;

    if (selectedLayers.length==0) {
    alert(errorNoLayerSelected);
    } else {
    for (var i = 0; i &lt; selectedLayers.length; i++){
    selectedLayers[i].property("Rotation").expression = "Target 1";
    var effectLocation = selectedLayers[0].property("Effects");
    var effectCount = effectLocation.numProperties;
    for (var n = 0; n &lt; 5; n++){
    var addEffect = selectedLayers[0].property("Effects").addProperty("Layer Control");
    var nPlusOne = n+1
    addEffect.name = "target" + " \""+nPlusOne+"\" ";
    var addEffect = selectedLayers[0].property("Effects").addProperty("Slider Control");
    addEffect.name = "fade" + " \""+nPlusOne+"\" ";
    }
    for (var m = 1; m &lt;= 1; m++){
    var currentExpression = selectedLayers[0].property("Rotation").expression;
    selectedLayers[0].property("Rotation").expression = " \""+currentExpression+"\" " + "something";
    }

    }
    }
    }

    app.endUndoGroup();

    Sam Catt replied 8 years ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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