Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Match Properties Selection

  • Match Properties Selection

  • Rodrigo Kermessi

    December 28, 2022 at 1:42 pm

    Hi friends! Hope you´re all doing good!

    I´m trying to create a script that you can select layers and some properties and match the selection of the properties. I mean, all selected layers would have the same properties selected.

    I´m almost there, it works great with: position, rotation, scale, opacity. But, doesn´t work with any other property.

    Here is the script so far:

    <b style="">var myComp = app.project.activeItem;
    //selected properties
    var myProps = myComp.selectedProperties;
    for (var p = 0; p < myProps.length; p++){
    //selected layers
    var myLayers = myComp.selectedLayers;
    for (var l = 0; l < myLayers.length; l++){
    // select matched properties for selected layers
    myLayers[l].property(myProps[p].name).selected = true
    <b style="">}};
  • Rodrigo Kermessi

    December 28, 2022 at 2:49 pm

    Please, ignore both <b style=””> not sure how it appeared there.
    The right code (so far) would be:

    var myComp = app.project.activeItem;
    \\selected properties
    var myProps = myComp.selectedProperties;
    for (var p = 0; p < myProps.length; p++){
    \\selected layers
    var myLayers = myComp.selectedLayers;
    for (var l = 0; l < myLayers.length; l++){
    \\select matched properties for selected layers
    myLayers[l].property(myProps[p].name).selected = true

    }};

  • Dan Ebberts

    December 28, 2022 at 7:04 pm

    To do that, I think you have to build the property spec path on the fly, like this:

    var myComp = app.project.activeItem;
    var myProps = myComp.selectedProperties;
    for (var p = 0; p < myProps.length; p++){
    var myLayers = myComp.selectedLayers;
    for (var l = 0; l < myLayers.length; l++){
    var myProp = myProps[p];
    var myPropString = "";
    while (myProp.parentProperty !== null){
    var name = "\"" + myProp.name + "\"";
    myPropString = ".property" + "(" + name + ")" + myPropString;
    myProp = myProp.parentProperty;
    }
    if (myPropString != ""){
    eval("var myActualProp = myComp.layer('" + myLayers[l].name + "')" + myPropString + ";");
    myActualProp.selected = true;
    }
    }
    };
  • Rodrigo Kermessi

    December 28, 2022 at 9:13 pm

    Hi Dan, thank you so much, it worked perfectly.

    I´m a big fan of yours! It´s impressive that 99% of the thing that I had issues, like forever, about expressions and scripts for AE, was solved by you in some forum over the internet or even learning in the classic MotionScript.com. Legend!

    PS: The first plugins I ever bought was TypeMonkey and MotionMonkey. 🙂

    Best Wishes!

  • Dan Ebberts

    December 28, 2022 at 9:50 pm

    Thanks for the kind words! I appreciate it.

Viewing 1 - 5 of 5 posts

Log in to reply.

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