Activity › Forums › Adobe After Effects Expressions › Group shapes
-
Group shapes
Posted by Mahdi Mor on June 16, 2017 at 5:19 pmSanti Agustí replied 7 years, 1 month ago 4 Members · 15 Replies -
15 Replies
-
Dan Ebberts
June 16, 2017 at 5:50 pmThe only way I know of is to select the shapes and then have the script execute the “Group Shapes” menu command.
Dan
-
Dan Ebberts
June 16, 2017 at 7:12 pmSomething like this, probably:
var myContents = myLayer.property("ADBE Root Vectors Group");
myLayer.selected = false;
for (var i = 1; i <= myContents.numProperties; i++){
myContents.property(i).selected = true;
}
It might depend on how your shape layer is structured.
Dan
-
Juanluis Vich
March 9, 2019 at 1:40 amhi!
I was trying to group some shape props along a bunch of selected layers, but it seems I cannot make it work on all the selected layers, but only on the first one.
Is there a chance to make it work so I can select some layers, and then apply the script so all the contents they have inside get grouped without stoping once the first layer is done? Maybe that’s not possible and it should work on every layer individually?
this is the code I was trying to make work:
var myLayers = app.project.activeItem.selectedLayers;
var myLayer;
for (var i = 0; i < myLayers.length; i++){myLayer = myLayers[i];
var myContents = myLayer.property("ADBE Root Vectors Group");
myLayer.selected = false;
for (var i = 1; i <= myContents.numProperties; i++){
myContents.property(i).selected = true;
app.executeCommand(3741);//group shapes
}}
Thanks!
-
Dan Ebberts
March 9, 2019 at 3:11 amYou have a nested loop where you’re using the same loop variable name (i) for both loops. You need to change one of them. I usually use j for the inner loop.
Dan
-
Juanluis Vich
March 9, 2019 at 4:11 amoh! thanks! I missed that!
I changed the inner loop to be j, but it seems the execute command is not working at all. Its weird, when I select the layers individually, it works great, but if more than 1 layer is selected, it just loops and selects all the properties at the same but no grouping at all…
-
Dan Ebberts
March 9, 2019 at 4:35 amI don’t know for sure, but maybe the menu command doesn’t work if more than one layer is selected. If that’s the case, you’ll probably have to make sure the layers are selected one at a time before you start the inner loop.
Dan
-
Juanluis Vich
March 9, 2019 at 6:21 ammm yes, it seems it will have to work that way… thanks for the ideas!
-
Juanluis Vich
March 23, 2019 at 9:25 pmhi!
I’ve been trying to figure out how to make sure the layers are selected one at a time before starting the inner loop with no luck… do you have any hint or ref to get the right direction?
Thanks!
Reply to this Discussion! Login or Sign Up
