这是一个可以查找文件中专色和全局色的脚本,带对话框喔。
var mySpots = new Array();
var dp = 0;
var newSpot = app.activeDocument.spots;
for (var i = 0; i < newSpot.length; i += 1) {
mySpots.push(newSpot[i].name);
}
var myDialog = new Window("dialog", "AI文件中查找专色/全局色", undefined);
with(myDialog) {
myGuideTypesPanel = add("panel", undefined, "请选择一个专色或全局色名称:");
myGuideTypesPanel.preferredSize = [180, 60];
with(myGuideTypesPanel) {
myDialog.whichInfo = add("dropdownlist", undefined, mySpots);
whichInfo.preferredSize = [180, 20];
myDialog.whichInfo.onChange = function() {
for (var i = 0; i < myDialog.whichInfo.items.length; i += 1) {
if (myDialog.whichInfo.items[i].selected == true) {
dp = i;
}
}
};
myDialog.whichInfo.items[0].selected = true;
}
with(add("group")) {
orientation = "row";
alignment = "right";
add("statictext", undefined, "");
myDialog.myCloseButton = add("button", undefined, "取消", {
name: "cancel"
});
myDialog.myCloseButton.onClick = function() {
myDialog.close();
};
myDialog.myOKButton = add("button", undefined, "查找专色", {
name: "ok"
});
}
add("statictext", undefined, "By CPC:goldbridge 2008/7/15");
}
myDialog.center();
var myReturn = myDialog.show();
if (myReturn == true) {
zs = myDialog.whichInfo.items[dp].toString();
pth = app.activeDocument.pathItems;
for (var i = 0; i < pth.length; i += 1) {
if (pth[i].filled == true && pth[i].stroked == true) {
if (pth[i].fillColor.typename == "SpotColor" && pth[i].strokeColor.typename == "SpotColor") {
if (pth[i].fillColor.spot.name == zs || pth[i].strokeColor.spot.name == zs) {
pth[i].selected = true;
}
}
if (pth[i].fillColor.typename == "SpotColor" && pth[i].strokeColor.typename != "SpotColor") {
if (pth[i].fillColor.spot.name == zs) {
pth[i].selected = true;
}
}
if (pth[i].fillColor.typename != "SpotColor" && pth[i].strokeColor.typename == "SpotColor") {
if (pth[i].strokeColor.spot.name == zs) {
pth[i].selected = true;
}
}
}
if (pth[i].filled == false && pth[i].stroked == true) {
if (pth[i].strokeColor.typename == "SpotColor") {
if (pth[i].strokeColor.spot.name == zs) {
pth[i].selected = true;
}
}
}
if (pth[i].filled == true && pth[i].stroked == false) {
if (pth[i].fillColor.typename == "SpotColor") {
if (pth[i].fillColor.spot.name == zs) {
pth[i].selected = true;
}
}
}
}
txt = app.activeDocument.textFrames;
for (var i = 0; i < txt.length; i += 1) {
txt1 = txt[i].textRange.characterAttributes.fillColor;
txt2 = txt[i].textRange.characterAttributes.strokeColor;
try {
if (txt1.typename == "SpotColor") {
if (txt1.spot.name == zs) {
txt[i].selected = true;
}
}
if (txt2.typename == "SpotColor") {
if (txt2.spot.name == zs) {
txt[i].selected = true;
}
}
} catch (e) {
}
}
rst = app.activeDocument.rasterItems;
for (var i = 0; i < rst.length; i += 1) {
try {
if (rst[i].colorants == zs) {
rst[i].selected = true;
}
} catch (e) {
}
}
}