Copy link to clipboard
Copied
Hey! I have a super quick question that I have spend way to much time struggling with.
I am rewriting an action into a script file and I am looking for the correct way to add to a selection within a script, same as ctrl+shift clicking in photoshop. As of now I have the script selecting the layer mask, rotating the selection, and expanding the selection by 1%. The one step I am missing is adding the original layer mask selection back to the rotated selection.
The current code I have is
Here is a screenshot of the action
Here is a screenshot of the desired seleciton effect.
Here is the text of the code...
1 Correct answer
I don't believe that there is a native DOM method. Try this AM function, the layer with the mask has to be active/targeted:
addMaskSelToSel();
function addMaskSelToSel() {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "mask" ));
descriptor.putReference( s2t( "null" ), reference );
refe
...
Explore related tutorials & articles
Copy link to clipboard
Copied
If it helps this is the XML of the ATN
{
expanded: true,
enabled: true,
showDialogs: false,
dialogMode: 0,
commandName: 'Add',
descriptor: {
_obj: 'add',
_target: [
{
_ref: 'channel',
_enum: 'channel',
_value: 'mask'
}
],
to: [
{
_ref: 'channel',
_property: 'selection'
}
]
}
},
Copy link to clipboard
Copied
I don't believe that there is a native DOM method. Try this AM function, the layer with the mask has to be active/targeted:
addMaskSelToSel();
function addMaskSelToSel() {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "mask" ));
descriptor.putReference( s2t( "null" ), reference );
reference2.putProperty( s2t( "channel" ), s2t( "selection" ));
descriptor.putReference( s2t( "to" ), reference2 );
executeAction( s2t( "add" ), descriptor, DialogModes.NO );
}
Copy link to clipboard
Copied
An alternative approach, rather than adding to the current selection, use Quick Mask mode for a hybrid channel/selection approach... Again, presuming that the correct layer is targeted:
// Enter QM mode
activeDocument.quickMaskMode = true;
// Load selection from layer mask
maskToSelection();
// Clear/delete
activeDocument.selection.clear();
// Exit QM mode
activeDocument.quickMaskMode = false;
///// Functions /////
function maskToSelection() {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putProperty( s2t( "channel" ), s2t( "selection" ));
descriptor.putReference( s2t( "null" ), reference );
reference2.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "mask" ));
descriptor.putReference( s2t( "to" ), reference2 );
executeAction(s2t( "set" ), descriptor, DialogModes.NO);
}
Copy link to clipboard
Copied
@J.C.C.1 - So how did you go?
Copy link to clipboard
Copied
The first answer worked perfectly. As always thanks for your help @Stephen Marsh!

