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