function main() {
if (app.documents.length == 0) {
alert("請至少打開一個文檔")
return
}
var spotList = []
var doc = app.activeDocument
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", "我要自學網案例-刪除專色色塊")
if (spotList.length == 0) {
win.margins = 50
win.add("staticText", undefined, "當前文檔專色數量為: 零")
} else {
win.add("staticText", undefined, "當前文檔共有 " + spotList.length + " 個專色, 選擇想要刪除的專色")
var pan = win.add("panel")
pan.orientation = "row"
pan.alignChildren = "top"
var checkboxList = []
var tempGroup = null
for(var i =0; i<spotList.length; i++){
if(i % 10 == 0){
tempGroup = pan.add("group")
tempGroup.orientation = "column"
tempGroup.alignChildren = "left"
}
var cck = tempGroup.add("checkbox", undefined, spotList[i].name)
checkboxList.push(cck)
}
var actionGroup = win.add("group")
actionGroup.margins = 20
var alltBtn = actionGroup.add("button", [0, 0, 60, 30], "全選")
var okBtn = actionGroup.add("button", [0, 0, 60, 30], "執(zhí)行")
var reBtn = actionGroup.add("button", [0, 0, 60, 30], "反選")
alltBtn.onClick = function(){
for(var i = 0; i<checkboxList.length; i++){
checkboxList[i].value = true
}
}
reBtn.onClick = function(){
for(var i = 0; i<checkboxList.length; i++){
if(checkboxList[i].value){
checkboxList[i].value = false
}else{
checkboxList[i].value = true
}
}
}
okBtn.onClick = function(){
for(var i = 0; i<checkboxList.length; i++){
if(checkboxList[i].value){
// 刪除
spotList[i].remove()
}
}
win.close()
}
}
win.center()
win.show()
}
main()
承擔因您的行為而導致的法律責任,
本站有權保留或刪除有爭議評論。
參與本評論即表明您已經閱讀并接受
上述條款。