Loop iterates infinitely when trying to work with LayarSets

New Here ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

I wrote a small script that should display the number of objects inside the group and the name of the groups (only the first nesting level), but the script loops endlessly, who has already encountered this, can you tell me what the problem is?

#target photoshop

var docRef = app.activeDocument;

var myGroups = docRef.layerSets;

alert(myGroups.length);

for( i = 0; i < myGroups.length ; i++) {
    try{
        alert(myGroups[i].name);
        alert(myGroups[i].layers.length);
    }catch(e){}
};

 

TOPICS
Actions and scripting , Windows

Views

58

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

I don't see any problem in this code ¯ \ _ (ツ) _ / ¯

Have you tried it on different documents with different number of groups and always observed this behavior?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

LATEST

What does endlessly mean? What do the alerts show and how do you run the script? Is this the complete code?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines