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

inconsistencies when a group is selected

Participant ,
Jul 16, 2025 Jul 16, 2025

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.

TOPICS
Actions and scripting
195
Translate
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 1 Correct answer

Mentor , Jul 17, 2025 Jul 17, 2025

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.

 

Translate
Adobe
Participant ,
Jul 16, 2025 Jul 16, 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.

Translate
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
Mentor ,
Jul 16, 2025 Jul 16, 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);

 

Translate
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 ,
Jul 16, 2025 Jul 16, 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.

Translate
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 17, 2025 Jul 17, 2025

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

Translate
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
Mentor ,
Jul 17, 2025 Jul 17, 2025
LATEST

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.

 

Translate
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