I currently have a active selection set and I want to apply the selection to a groups mask. Is there a way of doing this with out using batch play/alchemist? If not why is my batchplay not working? This is the pop-up i receive with the current code:
If there is a way of doing this without batchplay and in the context of a uxp/photoshop plugin I would love to know.
Thanks in advance!
import {app, action, core} from 'photoshop';
async function makeSelectionTop() {
await action.batchPlay(
[
{
_obj: "set",
_target: [
{
_ref: "channel",
_property: "selection"
}
],
to: {
_obj: "rectangle",
top: {
_unit: "pixelsUnit",
_value: 0
},
left: {
_unit: "pixelsUnit",
_value: 0
},
bottom: {
_unit: "pixelsUnit",
_value: 1664
},
right: {
_unit: "pixelsUnit",
_value: 2300
}
},
_options: {
// dialogOptions: "dontDisplay"
}
}
],
{}
);
}
async function makeSelectionBottom() {
console.log("Hey")
await action.batchPlay(
[
{
_obj: "set",
_target: [
{
_ref: "channel",
_property: "selection"
}
],
to: {
_obj: "rectangle",
top: {
_unit: "pixelsUnit",
_value: 1708
},
left: {
_unit: "pixelsUnit",
_value: 0
},
bottom: {
_unit: "pixelsUnit",
_value: 2608
},
right: {
_unit: "pixelsUnit",
_value: 2300
}
},
_options: {
// dialogOptions: "dontDisplay"
}
}
],
{}
);
}
async function snap(){
await action.batchPlay(
[
{
_obj: "move",
_target: [{ _ref: "layer", _enum: "ordinal", _value: "targetEnum" }],
to: {
_obj: "offset",
horizontal: { _unit: "pixelsUnit", _value: 0 },
vertical: { _unit: "pixelsUnit", _value: -286 }
},
}
],
{}
);
}
async function test(){
await action.batchPlay(
[
{
_obj: "make",
new: {
_class: "channel"
},
at: {
_ref: "channel",
_enum: "channel",
_value: "mask"
},
using: {
_enum: "userMaskEnabled",
_value: "revealSelection"
},
_options: {
dialogOptions: "dontDisplay"
}
}
],
{}
);
}
async function template(){
await core.executeAsModal(async (executionContext, descriptor) => {
let doc = app.activeDocument
// Resize Image Width
await doc.resizeImage(2300)
// Duplicate layer
let model = await doc.activeLayers[0].duplicate()
// Resize Canvas Height
await doc.resizeCanvas(2300, 2600)
// Create Group Container For Model
const modelGroup = await doc.createLayerGroup({
name: "Model", visible: true, fromLayers: [model]
})
await snap()
await test()
await makeSelectionTop()
// await makeSelectionBottom()
});
}
export default template