Skip to main content
New Participant
July 18, 2022
Answered

Action or Script to Expand ( unfold ) Layer Groups. ?

  • July 18, 2022
  • 2 replies
  • 2469 views

Bare with me, I know nothing useful about scripting.
I am building an action that contains several steps, one of the steps involves duplicating a layer group and then selecting a layer inside that layer group. I cannot find any way to open ( unfold ) a layer group. Selecting, 'next' or 'previous' only selects the top layers and does not open the group. Any suggestions would be greatly appreciated.

 

🙂

 

Correct answer jazz-y
var g = (ad = activeDocument).activeLayer; if (g.typename == 'LayerSet' && g.layers.length) ad.activeLayer = g.layers[0]; ad.activeLayer = g

2 replies

Jim.D.D.Author
New Participant
July 19, 2022

Thank you all for your help. 

Please forgive the extreme newbie question, but how exactly do I create this script? I am running CC2021 but I can't seem to find any information on what application to use just to simply build the script. Apparently ExtendScript is no longer available. I am on a mac running just Catalina. 

I know how to write some basic javascript inside After Effects expressions. I am just not sure what my starting point is or what app to use to actually write the script. 

Stephen Marsh
Adobe Expert
July 19, 2022
jazz-yCorrect answer
Brainiac
July 18, 2022
var g = (ad = activeDocument).activeLayer; if (g.typename == 'LayerSet' && g.layers.length) ad.activeLayer = g.layers[0]; ad.activeLayer = g
Stephen Marsh
Adobe Expert
July 18, 2022

@jazz-y – Great work as always!

 

This got me thinking, there is a native command to collapse all groups, however, there isn't one to collapse just the selected set. Can you post code for that, please?

 

Edit: I got that backwards... Additionally, as there is a collapse all groups command – what about a script to expand all groups?

 

 

Brainiac
July 19, 2022

There is a "layerSectionExpanded" key in PIStringTerminology.h. It probably describes the state of a particular group. I tried to use it in different ways, but did not succeed. As a workaround, we can save the group properties (name, blending mode, effects, etc.) as completely as possible, ungroup it and create again.

 

collapseAllGroupsEvent:

 

executeAction(stringIDToTypeID('collapseAllGroupsEvent'), new ActionDescriptor(), DialogModes.NO)