有没有办法在 Photoshop 中扩展组?

Is there a way to EXPAND a group in Photoshop?

在“图层”面板中,Photoshop 有一个 'Collapse All Groups' 的下拉选项。在 Javascript?

中是否有反向选项来扩展一个或所有组或一种方法

任何箍,要折叠所有组只需使用 Scriptlistner 代码:

function collapse_all_groups()
{
  // =======================================================
  var idcollapseAllGroupsEvent = stringIDToTypeID( "collapseAllGroupsEvent" );
  var desc46 = new ActionDescriptor();
  executeAction( idcollapseAllGroupsEvent, desc46, DialogModes.NO );
}

而且似乎没有“expandAllGroupsEvent”

不过,我最终还是找到了 answer here

function openAllLayerSets(parent)
{
    for (var setIndex = 0; setIndex < parent.layerSets.length; setIndex++) 
    {
        try
        {
          app.activeDocument.activeLayer = parent.layerSets[setIndex].layers[0];
        }
        catch(e)
        {
          alert(e + app.activeDocument.activeLayer);
        }
        openAllLayerSets(parent.layerSets[setIndex]);
    }
}

openAllLayerSets(app.activeDocument);

给你,答案来自

https://community.adobe.com/t5/photoshop/expand-collapse-a-group-via-javascript/td-p/7286289/page/2?page=1%3F

var groupname = app.activeDocument.activeLayer.name // name of active layer 
var idungroupLayersEvent = stringIDToTypeID( "ungroupLayersEvent" ); // ungroup layer event 

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  " ); // make action , note the space
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 " ); // <-- note the space
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