Activity › Forums › Adobe After Effects Expressions › Group shapes
-
Dan Ebberts
March 23, 2019 at 10:02 pmFirst you would loop through all currently selected layers and deselect each one. Then you would select the layer you want to apply the preset to.
Dan
-
Juanluis Vich
March 23, 2019 at 10:44 pmof course!
thanks!I made it work with this
Do you think the code is ok, or too messy? it’s working, btw ☺var myComp = app.project.activeItem;
var mySelectedLayers = myComp.selectedLayers;
///
for (var i = 1; i <= myComp.numLayers; i++){
myComp.layer(i).selected = false;}
///
for (var i = 1; i <= myComp.numLayers; i++){
var myContents = myComp.layer(i).property("ADBE Root Vectors Group");for (var j = 1; j <= myContents.numProperties; j++){
myContents.property(j).selected = true;
app.executeCommand(3741);//group shapes}
myComp.layer(i).selected = false;
} -
Dan Ebberts
March 23, 2019 at 11:44 pmI think I might change that first loop to something like this:
for (var i = 0; i < mySelectedLayers.length; i++){
mySelectedLayers[i].selected = false;
}
but it looks pretty good.
Dan
-
Santi Agustí
March 25, 2019 at 3:17 amHi! sorry to bother with the group thing! I was giving a try to the script you posted here with different kind of grouping ( shape layer with 4 pre- groups to group, another shape layer with 3 and 2).
Then I found a really odd behaviour when applying the script, it generates a group with several unexpected subgroups, it always creates the same pattern, groups inside groups,( and letting one element outside the group and when selecting more than 2 groups to group).I added an image to try to make it a bit more clear.

On the image, I was trying to group the groups (001,002,003,004) into a single group, but everything seemed to work with that strange behaviourI also added the same file I was applying the script into, just in case
13221_groupsmadness.aep.zipI don’t know if there is some line to tweak the script to avoif that infinite looping of creating subgroups when calling the command (3741) or maybe its some kind of bug or limitation when grouping via calling the command with the script?
Reply to this Discussion! Login or Sign Up