Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Iterate script for all selected layers?

  • Iterate script for all selected layers?

  • Kevin Snyder

    December 27, 2022 at 5:47 pm

    I have this script working for my selected properties on a single layer. However, I’m trying to get it to work on multiple layers simultaneously, but I’m not able to get it to work. I think the problem has to do with line 3, but I don’t know how to tackle it. Thanks.

    function myBridgeController(myBridge){

    var myComp = app.project.activeItem;

    var myLayers = myComp.selectedLayers[0];

    var myProps = myLayers.selectedProperties;

    var myControl = app.project.activeItem.layer(myBridge);

    if (!myControl){

    var controller = app.project.activeItem.layers.addNull();

    controller.name = myBridge;

    controller.enabled = false;

    }

    for (var i = 0; i < myProps.length; i++){

    var myEffect = myComp.layer(myBridge).Effects.addProperty("ADBE Checkbox Control");

    myEffect.name = myBridge + " " + myLayers.name + " " + myProps[i].name;

    var myExpr = 'thisComp.layer("' + myBridge + '").effect("' + myEffect.name + '")("Checkbox");';

    myNewProp = myComp.layer(myBridge).property("Effects").property(myEffect.name).property("Checkbox");

    myNewProp.addToMotionGraphicsTemplateAs(myComp, myEffect.name);

    myProps[i].selected = true;

    myProps[i].expression = myExpr;

    }

    }

  • Dan Ebberts

    December 27, 2022 at 10:24 pm

    I’m not sure, but if you’re planning on looping this through multiple layers, I think you first need to save the state of which layers and properties are currently selected, because the actions of your function will change that. So you’d need to restore those selections each time through the loop, or change the function to expect layer names and property path specs. It could be tricky, and a little messy.

  • Kevin Snyder

    December 27, 2022 at 10:57 pm

    Thanks, Dan. I appreciate the feedback. I thought that I may have been overlooking something obvious.

Viewing 1 - 3 of 3 posts

Log in to reply.

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