Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Get layer from selected property (in a script)

  • Get layer from selected property (in a script)

  • Pierre-Alain Lécroart

    May 4, 2020 at 10:00 am

    Hi !

    Disclaimer : I’m doing my first script ever

    I’m looking for a function that would help me retrieve the layer of a selected property.
    If I have this line :

    //Get selected property
    var myProperty = app.project.activeItem.selectedProperties[0];

    How can I do something like this :

    //Get layer of selected property
    var myLayer = myProperty.parentLayer;

    For now, my only solution is to stack a bunch of “.parentProperty” until I get something that I want but I don’t find this really clean ☺

    var selectedProperties = app.project.activeItem.selectedProperties;
    for(var i=0; i < selectedProperties.length; i++) {
    //If property is a group, try next property
    if (selectedProperties[i].canAddProperty) {
    continue;
    }
    var test = app.project.activeItem.selectedProperties[0].parentProperty.parentProperty.property("ADBE Effect Parade");
    //Property is in a property from an effect
    if (test == "Effects") {
    var myLayer = app.project.activeItem.selectedProperties[i].parentProperty.parentProperty.parentProperty;
    }
    //Property is a transform property
    else {
    var myLayer = app.project.activeItem.selectedProperties[i].parentProperty;
    }
    }

  • Dan Ebberts

    May 4, 2020 at 5:53 pm

    Try this:

    var myProperty = app.project.activeItem.selectedProperties[0];
    var myLayer = myProperty.propertyGroup(myProperty.propertyDepth);

    Dan

  • Pierre-Alain Lécroart

    May 4, 2020 at 6:20 pm

    Perfect solution ! Thanks a lot Dan.

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