function main() {
try {
app.activeDocument
} catch (error) {
alert('請(qǐng)至少打開(kāi)一個(gè)文檔.', "提示")
return
}
var doc = app.activeDocument
// 獲取專(zhuān)色列表
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", "我要自學(xué)網(wǎng)案例-刪除文檔的專(zhuān)色")
if (spotList.length == 0) {
win.margins = 50
win.add('statictext', undefined, '當(dāng)前文檔專(zhuān)色數(shù)量為 "零" ');
} else {
win.add('statictext', undefined, "當(dāng)前文檔共 " + spotList.length + " 個(gè)專(zhuān)色, 選擇想要?jiǎng)h除的專(zhuān)色");
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 + " 個(gè)專(zhuān)色")
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()
承擔(dān)因您的行為而導(dǎo)致的法律責(zé)任,
本站有權(quán)保留或刪除有爭(zhēng)議評(píng)論。
參與本評(píng)論即表明您已經(jīng)閱讀并接受
上述條款。