Skip to main content
Known Participant
March 27, 2024
Answered

Load selection of all masks inside a group

  • March 27, 2024
  • 2 replies
  • 3483 views

Hi!

 

I am having a hard time trying to load the selection of all the layer masks inside a group. The group can contain different numbers of layers that contain layer masks (names of the layers will be different, but the group name is always the same) . I would like to have a selection of all layer masks, like clicking on the mask with cmd+shift.

 

I don’t quite understand how loops work, and I am struggling to make it work.

 

This topic has been closed for replies.
Correct answer c.pfaffenbichler

It works, even though I get a message specifying the layer name and index. In line 118, I can modify what is shown in the message, but I don't know a way to avoid it altogether.


Sorry, must have forgotten that; just delete the line 

alert (theGroup.join("\n"));

altogether.  

2 replies

Legend
March 27, 2024

Why do you need this selection? In general, it is useless

 

martisansAuthor
Known Participant
March 28, 2024

We have some layers of effects that we only want to affect the visible part of the layers inside the group. We can clip them to the group, but to reduce the file size, we delete the parts of the image that are not in use (the black parts of the mask). 

It probably doesn't make sense to you, but it is useful to us.

c.pfaffenbichler
Community Expert
Community Expert
March 27, 2024

What is the problem exactly? 

Please provide a sample file. 

martisansAuthor
Known Participant
March 27, 2024

I think I missed the word script in my message. I am looking for a way to automate loading selections of all the masks of the layers within a group. I attached a small psd file with a group with two layers, hope I made it easier to understand now.

martisansAuthor
Known Participant
March 27, 2024

You specifically stated »names of the layers will be different, but the group name is always the same«. 

 

You can either insert the correct name instead of »group name« in the line 

var theLayers = collectLayersInGroupOfName ("group name");

or adapt the Script to take other input (the selected layer’s/group’s name, text input, …). 


Yes, I know I can change easily the name of the group. The script doesn't work if there are two groups in the same file. The "group name" and another one with a random name.

Thank you again for this.