ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Access each Shape layer group with a specific name

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Reuben Lara
Access each Shape layer group with a specific name
on Sep 28, 2019 at 11:16:49 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!


Return to posts index

Dan Ebberts
Re: Access each Shape layer group with a specific name
on Sep 29, 2019 at 6:24:02 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



Return to posts index

Reuben Lara
Re: Access each Shape layer group with a specific name
on Sep 29, 2019 at 11:43:29 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]