How To Expand A Group

I have recorded an action in Alchemist to create 3 adjustment layers and add them to a Group which is all fine.

I am tryiing to work out how to then Expand that group upon completion but Alchemist does not seem to listen to that event.

Anyone got any suggestions

I’m not sure you can expand a group programmatically.

One approach / workaround could be to create a group at the very first step of your recorded action. Before adding layers that you want to have inside that group. Make sure to select that new group, and then add adjustments layers to it. The group should remain open at all times.

Further, collapsing a group with batchPlay can be done using:

await batchPlay(
[
   // collapse current selected group
      {
        "_obj": "collapseAllGroupsEvent",
        "_isCommand": true,
        "_options": {
          "dialogOptions": "dontDisplay"
        }
      }
],{});
1 Like

Thanks @Pierre_G that solution worked out great. :smiley:

Thank you for your help.

How to collapse only the selected groups, but not all groups?

I’m afraid it’s not possible

It is, but requires some ugly workaround:

  1. Read out child layers of the group
  2. Store their ids (or other referenceable property)
  3. Ungroup (Delete group & Keep contents)
  4. Select remembered layers
  5. Regroup them

I have built a function with which you can open and close a group. With the option “recursive” you can say if all subfolders should also be closed or opened.

const photoshop = require("photoshop");

const collapseFolder = (expand = false, recursive = false) => {
    try {
        photoshop.action.batchPlay(
            [
                {
                    _obj: "set",
                    _target: {
                        _ref: [
                            {_property: "layerSectionExpanded"},
                            {
                                _ref: "layer",
                                _enum: "ordinal",
                                _value: "targetEnum",
                            }
                        ],
                    },
                    to: expand,
                    recursive,
                    _options: {dialogOptions: "dontDisplay"},
                },
            ],
            {synchronousExecution: true}
        );
    } catch (e) {
        console.error(e.message);
    }
}

I hope this helps

8 Likes

That’s awesome, thank you!

Thank you very much. I like this.