function main() {
try {
app.activeDocument
} catch (error) {
alert('請至少打開一個文檔.', "提示")
return
}
var doc = app.activeDocument
// 獲取專色列表
var spotList = []
for (var i = 0; i < doc.spots.length; i++) {
if (doc.spots[i].colorType == ColorModel.SPOT) {
spotList.push(doc.spots[i])
}
}
var win = new Window("dialog", "我要自學網(wǎng)案例-刪除文檔的專色")
if (spotList.length == 0) {
win.margins = 50
win.add('statictext', undefined, '當前文檔專色數(shù)量為 "零" ');
} else {
win.add('statictext', undefined, "當前文檔共 " + spotList.length + " 個專色, 選擇想要刪除的專色");
var panelLocation = win.add("panel", undefined, "")
var checkboxGroup = panelLocation.add("group", undefined)
checkboxGroup.orientation = "row"
checkboxGroup.alignChildren = "top"
var splitNum
if (spotList.length < 50) {
splitNum = 5
} else if (spotList.length < 100) {
splitNum = 10
} else if (spotList.length < 200) {
splitNum = 20
}
var checkBoxList = []
var tempGroup = checkboxGroup
for (var i = 0; i < spotList.length; i++) {
if (i % 10 == 0) {
tempGroup = checkboxGroup.add("group")
tempGroup.orientation = "column"
tempGroup.alignChildren = "left"
}
checkBoxList.push(tempGroup.add("checkbox", undefined, spotList[i].name))
}
var btnGroup = win.add("group", undefined)
var allBtn = btnGroup.add("button", undefined, "全選")
var goBtn = btnGroup.add("button", undefined, "執(zhí)行")
var reAllBtn = btnGroup.add("button", undefined, "反選")
allBtn.onClick = function () {
for (var i = 0; i < checkBoxList.length; i += 1) {
checkBoxList[i].value = true
}
}
reAllBtn.onClick = function () {
for (var i = 0; i < checkBoxList.length; i += 1) {
if (checkBoxList[i].value) {
checkBoxList[i].value = false
} else {
checkBoxList[i].value = true
}
}
}
goBtn.onClick = function () {
var count = 0
for (var i = 0; i < checkBoxList.length; i += 1) {
if (checkBoxList[i].value) {
spotList[i].remove()
count = count + 1
}
}
alert("刪除成功, 共刪除 " + count + " 個專色")
app.redraw()
win.close()
}
}
win.onClose = function () {
panelHeight = win.bounds.height;
for (var i = 50; i >= 1; i += -2) {
win.opacity = i / 50;
$.sleep(1);
win.bounds.height = panelHeight * (i / 50);
}
$.sleep(100);
callMe()
}
win.center()
win.show()
}
main()
承擔因您的行為而導致的法律責任,
本站有權保留或刪除有爭議評論。
參與本評論即表明您已經(jīng)閱讀并接受
上述條款。