跳转到内容

色板

app.activeDocument.swatches

文档中 Swatch 对象的集合。


app.activeDocument.swatches.length

集合中的元素数量。

数字;只读。


app.activeDocument.swatches.parent

对象的容器。

对象;只读。


app.activeDocument.swatches.typename

对象的类名。

字符串;只读。


app.activeDocument.swatches.add()

创建一个新的 Swatch 对象。

Swatch


app.activeDocument.swatches.getByName(name)

获取集合中第一个具有指定名称的元素。

参数类型描述
name字符串要获取的元素的名称

Swatch


app.activeDocument.swatches.getSelected()

获取文档中选中的色板。

Swatch 列表


app.activeDocument.swatches.index(itemKey)

从集合中获取一个元素。

参数类型描述
itemKey字符串, 数字要获取的元素的键

Swatch


app.activeDocument.swatches.removeAll()

删除集合中的所有元素。

无。


// 从当前文档中删除第4个色板
if ( app.documents.length > 0 ) {
if (app.activeDocument.swatches.length > 4) {
var swatchToDelete = app.activeDocument.swatches[3];
swatchToDelete.remove();
}
}