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

Expand / collapse a group via JavaScript?

Participant ,
Jun 23, 2015 Jun 23, 2015

Copy link to clipboard

Copied

I work with a lot of groups (layersets) that contain content that clutters the screen.  It would be great to use some ExtendScript command to collapse groups (similar to pressing the triangle next to the group, not talking about visibility).  Is there a way to do this?  The Script Listener does not record any code when doing this, and I can't find any documentation on it.  But it seems like something that should be addressable in code.  Thanks for any suggestions!

TOPICS
Actions and scripting

Views

6.6K

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 2 Correct answers

Community Beginner , Feb 15, 2016 Feb 15, 2016

Hi 😃

I had this broblem too. But i found a answer. It strange a little bit, but it works.

So, we have a layers in the group, and group is expand. Group is a acive layer.

var groupname = app.activeDocument.activeLayer.name // remember name of group

var idungroupLayersEvent = stringIDToTypeID( "ungroupLayersEvent" ); // this part from  Script Listene -- ungroup group

var desc14 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref13 = new ActionReference();

var idLyr = charIDToTy

...

Votes

Translate

Translate
People's Champ , Jan 31, 2019 Jan 31, 2019

Type in search collapseAllGroupsEvent

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 23, 2015 Jun 23, 2015

Copy link to clipboard

Copied

If I remember correctly there was a work-around, probably the thread was over at the now-defunct ps-scripts.com.

You might be able to find something in the archive:

ps-scripts.com • Index page

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
Enthusiast ,
Jun 24, 2015 Jun 24, 2015

Copy link to clipboard

Copied

The work-a-round could be these scripts here.

buliarca's scripts BCM Tools

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
Participant ,
Jun 24, 2015 Jun 24, 2015

Copy link to clipboard

Copied

Thanks!

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
Participant ,
Jun 24, 2015 Jun 24, 2015

Copy link to clipboard

Copied

While this script definitely works as advertised, it takes a very roundabout approach.  I'm concerned with potential robustness, as well as speed on complex images.  If anyone knows a more direct option to open/close layer sets, would love any suggestions.  Thanks!

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 Beginner ,
Feb 15, 2016 Feb 15, 2016

Copy link to clipboard

Copied

Hi 😃

I had this broblem too. But i found a answer. It strange a little bit, but it works.

So, we have a layers in the group, and group is expand. Group is a acive layer.

var groupname = app.activeDocument.activeLayer.name // remember name of group

var idungroupLayersEvent = stringIDToTypeID( "ungroupLayersEvent" ); // this part from  Script Listene -- ungroup group

var desc14 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref13 = new ActionReference();

var idLyr = charIDToTypeID( "Lyr " );

var idOrdn = charIDToTypeID( "Ordn" );

var idTrgt = charIDToTypeID( "Trgt" );

ref13.putEnumerated( idLyr, idOrdn, idTrgt );

desc14.putReference( idnull, ref13 );

executeAction( idungroupLayersEvent, desc14, DialogModes.NO );

var idMk = charIDToTypeID( "Mk  " ); // this part from  Script Listene --  group selected layers

var desc15 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref14 = new ActionReference();

var idlayerSection = stringIDToTypeID( "layerSection" );

ref14.putClass( idlayerSection );

desc15.putReference( idnull, ref14 );

var idFrom = charIDToTypeID( "From" );

var ref15 = new ActionReference();

var idLyr = charIDToTypeID( "Lyr " );

var idOrdn = charIDToTypeID( "Ordn" );

var idTrgt = charIDToTypeID( "Trgt" );

ref15.putEnumerated( idLyr, idOrdn, idTrgt );

desc15.putReference( idFrom, ref15 );

executeAction( idMk, desc15, DialogModes.NO );

app.activeDocument.activeLayer.name = groupname // recall group name

P.S. Sorry of my english. It doesn't my mother tonque.

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
Participant ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

Works when multiple layers are selected.  Any idea how to create a closed group that only contains a single layer?

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
Explorer ,
May 09, 2017 May 09, 2017

Copy link to clipboard

Copied

A workaround could be to create a temporary layer inside the group, then to use the above script by Vova_p, and then to delete the temp layer ?

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
Explorer ,
May 10, 2017 May 10, 2017

Copy link to clipboard

Copied

Sorry, my suggestion was loosy. The last step would reopen the group!

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
Explorer ,
May 10, 2017 May 10, 2017

Copy link to clipboard

Copied

I spoke too fast (well... Ok...lesson learned). It's possible too delete the temp layer without reopen the group.

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 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

It has been a few years, however, it is still a great answer Vova_p!

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
Participant ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

the suggestions listed here so far work under limited assumptions. But closing a group this way removes a lot of information from the group: layer styles, lock status, color, blendIf, opacity changes, etc.

Is there no JSX command to do it without altering the group?

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
People's Champ ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

Type in search collapseAllGroupsEvent

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
Participant ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

Thank you

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 ,
Aug 10, 2022 Aug 10, 2022

Copy link to clipboard

Copied

LATEST

I have extended the script from @Vova_p and collected some related scripts here:

 

https://gist.github.com/MarshySwamp/a39e3e1efee41174b3b92ee68c40fcd8

 

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