Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Can you expand action steps you are having trouble with and post a screenshot here?
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now