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.

c.pfaffenbichler
Community Expert
Community Expert
March 27, 2024

I do not have more than one group with the same name. Doing some tests now, I can see that I get errors with group names that include [square brackets]. I did a recording showing the error just by adding the brackets in the name.


That’s why it matters to provide meaningful test files. 

 

You can change the code to use a String instead of a RegExp and then change the check from »match« to »==«.