Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Apply expression to another layer's property based on current layer's selection

  • Apply expression to another layer's property based on current layer's selection

    Posted by Kevin Snyder on October 4, 2021 at 3:21 pm

    I don’t know if this is possible with a script, but would it be possible to apply an expression to a layer based on the current selection on a different layer? In the example image, I would like to make the Blur Amount slider on the Master Control layer the control for the Blur Radius which is located on the Square layer without having to use the pick whip.

    So, the workflow would be to select the Blur Radius on the Square layer, run the script, and the necessary expression would be written to the Blur Amount slider on the Master Control layer. I would appreciate any insight. Thanks.

    Kevin Snyder replied 4 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    October 4, 2021 at 7:42 pm

    Your question is somewhat confusing, because first you say:

    >I would like to make the Blur Amount slider on the Master Control layer the control for the Blur Radius which is located on the Square layer

    But then you say:

    >…and the necessary expression would be written to the Blur Amount slider on the Master Control layer.

    So I’m not sure what you’re after. To be clear though, an expression can only affect the property hosting the expression, so if you want the expression to control the Blur Radius on the Square layer, that’s where the expression would have to be applied.

  • Kevin Snyder

    October 4, 2021 at 9:11 pm

    Here’s what I was hoping to do:

    1. Select <b style=”font-family: inherit; font-size: inherit;”>Blur Radius on the <b style=”font-family: inherit; font-size: inherit;”>Square layer.

    2. Run a script.

    3. Result is that on the Blur Amount Slider found on the Master Control layer an expression is written: thisComp.layer(“square”).effect(“Fast Box Blur”)(“Blur Radius”)

    It would be great if the expression is written to the Blur Amount Slider to reflect whatever is selected in the comp.

    Let me know if that makes sense and is even possible. Thanks.

  • Dan Ebberts

    October 4, 2021 at 10:37 pm

    It’s possible if all you’re interested in is the very specific case you mention: the script checks to see if the Blur Radius property is selected, and if so, builds an expression to that property and applies it to the Master Control layer’s Blur Amount slider. However, it gets a lot more complicated in a hurry if you’re looking for a general solution that has to figure out which control on the Master Control layer gets the expression, based on what type of property is selected, or if the selected property might be something other than Fast Box Blur’s Blur Radius.

    Assuming that your goal is just the specific case you mentioned it might look like this:

    var myComp = app.project.activeItem;

    var myProps = myComp.selectedProperties;

    var myLayer = null;

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

    if (myProps[i].propertyType == PropertyType.PROPERTY && myProps[i].name == "Blur Radius" && myProps[i].parentProperty.name == "Fast Box Blur"){

    myLayer = myProps[i].parentProperty;

    while (myLayer.parentProperty != null){

    myLayer = myLayer.parentProperty;

    }

    var myExpr = 'thisComp.layer("' + myLayer.name + '")("Effects")("Fast Box Blur")("Blur Radius")';

    myComp.layer("Master Control").property("Effects").property("Blur Amount").property("Slider").expression = myExpr;

    break;

    }

    }

    But as I mentioned, anything more general this, while certainly possible, gets messy in a hurry.

  • Kevin Snyder

    October 5, 2021 at 3:21 pm

    Thanks for this Dan. I appreciate you taking the time. I was thinking that it would be great to have the ability to select any property, but I can see how that would get complicated. Thanks again.

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