• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to collapse a layer by javascript?

Engaged ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

Hello,

 

I looking for the commands in javscript to collapse/fold and extend/unfold a layer and/or a group in Illustrator. 

 

Thanks for any hints or tips in advance,

jens

TOPICS
Scripting

Views

389

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

correct answers 1 Correct answer

Guide , Jul 29, 2022 Jul 29, 2022

As @Charu Rajput said, collapsing layers is almost certainly not possible.  I was however able to expand all layers with items in them.  As an action, record the command "Locate object" from the layers panel menu.  In the script, iterate the top level layers and call the action each time. 

 

var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
    app.selection = null;
    layers[i].hasSelectedArtwork = true;
    app.doScript("Action 1", "Set 1");
}

 

Votes

Translate

Translate
Adobe
Adobe Employee ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

Hello @Parts4Arts,

 

Thanks for reaching out. I would request you try the suggestions shared in this community post (https://community.adobe.com/t5/photoshop-ecosystem-discussions/expand-collapse-a-group-via-javascrip...) and check if it helps.

 

Looking forward to hearing from you.

 

Thanks,

Anubhav

Votes

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
Engaged ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

Hello and thank you for the link. However, the discussion is 7 years and not all downloads work anymore. Also, it is about photoshop there. I am looking for a solution for Illustrator.
To my knowledge there is no command like "stringIDToTypeID" in the javascript for Illustrator.

Votes

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
Community Expert ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

Hi @Parts4Arts 

As far as I know, not possible with scripting.

Below is the link that may help too

https://community.adobe.com/t5/illustrator-discussions/script-to-expand-and-or-collapse-layers/td-p/...

 

Best regards

Votes

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
Guide ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

As @Charu Rajput said, collapsing layers is almost certainly not possible.  I was however able to expand all layers with items in them.  As an action, record the command "Locate object" from the layers panel menu.  In the script, iterate the top level layers and call the action each time. 

 

var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
    app.selection = null;
    layers[i].hasSelectedArtwork = true;
    app.doScript("Action 1", "Set 1");
}

 

Votes

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
Engaged ,
Jul 30, 2022 Jul 30, 2022

Copy link to clipboard

Copied

LATEST

Hello and thanks for this information and idea using an action.

 

Have a good weekend.

– j.

Votes

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