illustrator脚本 #014 查找文件中的专色和全局色

这是一个可以查找文件中专色和全局色的脚本,带对话框喔。

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) {

        }
    }
}

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值