Photoshop CC Javascript - 删除/剪切选区

Photoshop CC Javascript - Remove / Cut a Selection

在 Photoshop CC Javascript - 我有以下代码,旨在从我的活动图层中删除 4 个不同的选择。选择是正确的,但我无法从 activeLayer 中删除或剪切选择。

var doc = app.activeDocument;
var obj = doc.activeLayer;

var top = [[0, 0], [0, small_indent], [doc_w, small_indent], [doc_w, 0]];
var left = [[0, 0], [0, doc_h], [small_indent, doc_h], [small_indent, 0]];
var right = [[doc_w-small_indent, 0], [doc_w-small_indent, doc_h], [doc_w, doc_h], [doc_w, 0]];
var bottom = [[0, doc_h-small_indent], [0, doc_h], [doc_w, doc_h], [doc_w, doc_h-small_indent]];

var selections = [top, left, right, bottom];

for (var i = 0; i < selections.length; i++) {
    doc.selection.select(selections[i]);
    doc.selection.remove(); 
}

但是这一行doc.selection.remove();导致以下错误

Error 24: doc.selection.remove is not a function.

我也试过了

doc.selection.cut();
obj.selection.remove();
obj.selection.cut();

它们会导致相同的错误。

根据 Adobe Photoshop CC Javascript Reference Document.Selection 对象没有 remove 方法。请尝试调用 clear

for (var i = 0; i < selections.length; i++) {
    doc.selection.select(selections[i]);
    doc.selection.clear(); 
}
doc.selection.deselect();