Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Add Effect to layers with expressions erros in all comps

  • Add Effect to layers with expressions erros in all comps

    Posted by Otávio Nascimento on November 11, 2022 at 3:38 pm

    How to add an effect to all layers with expression errors in all comps?

    I have this expression:

    var effectMatchName = "ADBE Fill";
    var comp = app.project.activeItem;
    for(var i = 1; i <= comp.numLayers; i++){
    comp.layer(i).Effects.addProperty(effectMatchName);
    }

    Dan Ebberts replied 3 years, 6 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    November 11, 2022 at 8:02 pm

    You’ll need a recursive property sniffer to check for expression errors. Something like this should be close:

    var foundOne;
    function processProperty(theProp){
    if (theProp.propertyType == PropertyType.PROPERTY){
    if (theProp.canSetExpression && theProp.expressionError != ""){
    foundOne = true;
    }
    }else{ // must be a group
    for (var i = 1; i <= theProp.numProperties; i++){
    if (! foundOne) processProperty(theProp.property(i));
    }
    }
    }
    var myComp, myLayer;
    for (var i = 1; i <= app.project.numItems; i++){
    if (app.project.item(i) instanceof CompItem){
    myComp = app.project.item(i);
    for (var j = 1; j <= myComp.numLayers; j++){
    myLayer = myComp.layer(j);
    if (! myLayer.locked){
    foundOne = false;
    processProperty(myLayer);
    if (foundOne){
    myLayer.property("Effects").addProperty("ADBE Fill");
    }
    }
    }
    }
    }
  • Otávio Nascimento

    November 11, 2022 at 9:58 pm

    Thank you Dan. It helps a lot. But maybe I need other solution for my problem:

    I made a plugin and used it a lot in my project. Now I want to add a ‘checkbox’ in my plugin. If I add it I will receive a warning in my project and will glitchy my project. There is a good solution for it?

    My idea was to remove the plugin from all the project and add after I edited the plugin but I noticed that I will lose the keyframes and expressions.

  • Dan Ebberts

    November 12, 2022 at 12:26 am

    It’s been a while since I’ve done much with plugin code, but I seem to recall that when you add a new control to your plugin, you just need to make and assign it a new, unique id and it should be backwards compatible. It sounds like you may have had a different experience.

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