Photoshop CC Javascript - Удалить / вырезать выделение - PullRequest
0 голосов
/ 15 ноября 2018

В Photoshop CC Javascript - у меня есть следующий фрагмент кода, целью которого является удаление 4 различных выделений из моего активного слоя.Выбор правильный, но я не могу удалить или вырезать его из активного слоя.

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();

И они приводят к одной и той же ошибке.

1 Ответ

0 голосов
/ 15 ноября 2018

Согласно Справочнику по Adobe Photoshop CC Javascript Document.Selection объект не имеет remove метода.Попробуйте позвонить clear.

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