Copy link to clipboard
Copied
Hi community!
How can I select all the items in the sublayer groups called "color" and "shadow"
My main group name in this example called "education-props" is different across all files. Only "color" and "shadow" is consistent and I need the items in these subgroups.
I'm completely new with scripting. Your help is much appreciated!
[ attachment inserted as inline image by moderator ]
Oh i think i figured it!
var docRef = app.activeDocument;
var layers = docRef.layers;
docRef.selection = null; //ensure there is nothing in the document selected already. this way you only get the selection you want.
for(var a=0;a<docRef.groupItems.length;a++){
if (docRef.groupItems[a].name == "shadow"){
docRef.groupItems[a].selected = true;
}
if (docRef.groupItems[a].name == "color"){
docRef.groupItems[a].selected = true;
}
}
Copy link to clipboard
Copied
Oh i think i figured it!
var docRef = app.activeDocument;
var layers = docRef.layers;
docRef.selection = null; //ensure there is nothing in the document selected already. this way you only get the selection you want.
for(var a=0;a<docRef.groupItems.length;a++){
if (docRef.groupItems[a].name == "shadow"){
docRef.groupItems[a].selected = true;
}
if (docRef.groupItems[a].name == "color"){
docRef.groupItems[a].selected = true;
}
}
Copy link to clipboard
Copied
This worked for me as well, been hours looking for something like this, thanks!
Copy link to clipboard
Copied
Good finding.
😉
Another variant (will be helpful if you have dozens of hundreds of groups)
var aDoc = app.activeDocument;
aDoc.selection = null;
// make sure the layer exists! or also use a try catch clause
var aLay = aDoc.layers.getByName("education-props");
var grp = null;
try {grp = aLay.groupItems.getByName("shadow");
grp.selected = true;
}
catch (e) {alert ("""there is no "shadow" group""")}
try {grp = aLay.groupItems.getByName("color");
grp.selected = true;
}
catch (e) {alert ("""there is no "color" group""")}
Copy link to clipboard
Copied
Danke dir, @pixxxelschubser deine Zeilen haben mir auch schon ein wenig weitergeholfen. Da ich leider überhaupt keinen Plan vom scripten habe kommt hier meine Frage:
Wie wähle ich eine Ebene aus, die noch eine Stufe tiefer sitzt?
In meinem Fall die Ebene "Background".
Danke schon mal im Voraus!
Just saw this was an english thread:
I want to select the sublayer "Background" in the image above.
Copy link to clipboard
Copied
What should the script do if the document contains many layers of the same name?