Skip to main content
Flowgun
Inspiring
July 17, 2025
Answered

inconsistencies when a group is selected

  • July 17, 2025
  • 3 replies
  • 249 views

when recording an action to load selection from a mask (ctrl+clicking the mask), the action works fine as long as we have a layer selected and not a group. The action will fail if we have a group selected.
I encountered the same problem with scripting:

    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty(cTID('Chnl'), sTID("selection"));
    desc1.putReference(cTID('null'), ref1);
    var ref2 = new ActionReference();
    ref2.putEnumerated(cTID('Chnl'), cTID('Chnl'), cTID('Msk '));
    ref2.putIdentifier(cTID('Lyr '), layerID);
    desc1.putReference(cTID('T   '), ref2);
    executeAction(cTID('setd'), desc1, DialogModes.NO);

 
I'd love to see that fixed and that we have a consistent outcome. but until then, is there any efficient workaround? I know I can temporarily create a layer and then load the selection and then delete the layer, but that's a lot of overhead.

Correct answer jazz-y

I confirm the problem - attempting to load a selection from a mask of any layer with a group active on the layers palette via a script or action results in a message saying that the command is unavailable. However, I don't think this is a bug, rather just a limitation of Photoshop's automation system.

 

3 replies

Flowgun
FlowgunAuthor
Inspiring
July 17, 2025

no, my code has a variable "LayerID" that targets whatever layer I want with its ID. the Action also doesn't work on a layer that still exists and has its mask, if we select a group before running it. This limitation makes no sense because we don't have to be on a layer to make a selection. Ctrl+click a mask while we currently have a group active works though.

Bojan Živković11378569
Community Expert
Community Expert
July 17, 2025

Can you expand action steps you are having trouble with and post a screenshot here?

Legend
July 17, 2025

Your code creates a selection from the active layer mask. If mask does not exist, it returns an error (not only for the group, but also for any other layer without a mask). And not only the script, but also the action. I assume that you recorded the action while on the active layer mask.


Specify what you are trying to do. If you need to create a selection by the transparency mask of the layer contents, then you need to use this code (and it will work fine with groups too):

 var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty(cTID('Chnl'), sTID("selection"));
    desc1.putReference(cTID('null'), ref1);
    var ref2 = new ActionReference();
    ref2.putEnumerated(cTID('Chnl'), cTID('Chnl'), sTID('targetEnum'));
    desc1.putReference(cTID('T   '), ref2);
    executeAction(cTID('setd'), desc1, DialogModes.NO);

 

Flowgun
FlowgunAuthor
Inspiring
July 17, 2025

I figured out that doc.activeLayer.kind fails within a try-catch if a group is selected, so in that case, I loop through the layers until it succeeds, select that layer with ActiveDocument.ActiveLayer := doc.Layers.Item(index) and exit the loop, then I reselect my group.