Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Access each Shape layer group with a specific name

  • Access each Shape layer group with a specific name

    Posted by Reuben Lara on September 28, 2019 at 11:16 pm

    Hey all!

    I am able to add an effect (in this case, Trim Paths) to the contents of a specific shape layer group named “path”. But when there is more than one group with the same name, it only targets the last one. Is there a way to loop through all of them individually? Here’s my setup:
    13760_screenshot20190928at7.03.52pm.png.zip

    This code works for one instance of “path” group:


    var mySelection = app.project.activeItem.selectedLayers;

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

    mySelection[i].property("Contents").property("path").property("Contents").addProperty("ADBE Vector Filter - Trim");

    }

    Trying to load all the groups named “path” into a variable and loop it, with no success:


    var mySelection = app.project.activeItem.selectedLayers;

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

    var pathGroup = mySelection[i].property("Contents").property("path");

    for (var n=0; n<pathGroup.length; n++){

    var trimPaths = pathGroup[n].property("Contents").addProperty("ADBE Vector Filter - Trim");

    }

    }

    Any ideas? Thanks!

    Reuben Lara replied 6 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 29, 2019 at 6:24 pm

    I’m not sure exactly how you have things set up, but in general I think you could do something like this:


    var n = mySelection[i].property("Contents").numProperties;

    for (var j = 1; j <= n; j++){
    if (mySelection[i].property("Contents").property(j).name == "path"){
    // do stuff
    }
    }

    Dan

  • Reuben Lara

    September 29, 2019 at 11:43 pm

    That was it, thanks so much! (And thank you for being some kind of omnipresent scripting genie that has helped so many people over the years… much appreciated!)

    Reuben

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