var doc = app.activeDocument;
app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
doc.rulerOrigin = [0, doc.height];
var lay = doc.activeLayer;
var ab = doc.artboards;
var arrSpotColor = new Array();
doc.selection = null;
var doc = app.activeDocument;
var swaSpot = doc.spots;
for (var i = 0; i < swaSpot.length; i += 1) {
if (swaSpot[i].colorType == "ColorModel.REGISTRATION") {
regName = swaSpot[i].name;
break;
}
}
var col1 = new CMYKColor();
col1.black = 0;
col1.magenta = 0;
col1.cyan = 100;
col1.yellow = 0;
var col2 = new CMYKColor();
col2.black = 0;
col2.magenta = 100;
col2.cyan = 0;
col2.yellow = 0;
var col3 = new CMYKColor();
col3.black = 0;
col3.magenta = 0;
col3.cyan = 0;
col3.yellow = 100;
var col4 = new CMYKColor();
col4.black = 100;
col4.magenta = 0;
col4.cyan = 0;
col4.yellow = 0;
var colAll = new Array();
colAll[0] = col1;
colAll[1] = col2;
colAll[2] = col3;
colAll[3] = col4;
var set = "Set_ClearUnuseSwatches";
var action1 = "Action_ClearUnuseSwatches";
var actionStr1 = ["/version 3", "/name [ 22", "5365745f436c656172556e7573655377617463686573", "]", "/isOpen 1", "/actionCount 1", "/action-1 {", "/name [ 25", "416374696f6e5f436c656172556e7573655377617463686573", "]", "/keyIndex 0", "/colorIndex 0", "/isOpen 1", "/eventCount 2", "/event-1 {", "/useRulersIn1stQuadrant 0", "/internalName (ai_plugin_swatches)", "/localizedName [ 8", "5377617463686573", "]", "/isOpen 0", "/isOn 1", "/hasDialog 0", "/parameterCount 1", "/parameter-1 {", "/key 1835363957", "/showInPalette -1", "/type (enumerated)", "/name [ 17", "\t53656c65637420416c6c20556e75736564", "]", "/value 11", "}", "}", "/event-2 {", "/useRulersIn1stQuadrant 0", "/internalName (ai_plugin_swatches)", "/localizedName [ 8", "5377617463686573", "]", "/isOpen 0", "/isOn 1", "/hasDialog 1", "/showDialog 0", "/parameterCount 1", "/parameter-1 {", "/key 1835363957", "/showInPalette -1", "/type (enumerated)", "/name [ 13", "\t44656c65746520537761746368", "]", "/value 3", "}", "}", "}"].join("\n");
var win = new Window("dialog", "(CJ)AI_色号生成器V2.2scD", undefined);
win.alignChildren = "fill";
win.spacing = 5;
var abIcon = "�PNG\r\n�\n\rIHDR���+v���tEXtSoftwareAdobe ImageReadyqÉe<�gIDATxÚ�U]L�e�~úÿµ�òñ_Ú��¿)Ð�p\tk�Hq!�É2.\\\"Ã�zåî6¹Ü¼äÆ+â¼r�Ù¸Ðx¡²�M�Ù�$j¢��¨c�]�)?V~V�´¥¿�ó�2ºà�'yó}mß÷y�ó�ç�ªðê¡x<�
_f(^å�úe?��A½^?©Õj�Ñòû|¾�½½½�è=ÓéüôÛ¸$I\nþOȲÜf±X�ÒJ××ק»:;ÓCCCélð{{{{º¼¬,Í{\n\n\nÆ���å�q4/~QQQ1¢Ñh¾-))±��EÁk§Natt�EEEb�ÝnG �@
Í�³Ù�½½=·ZöÒE?íììüu,x]]��ß´Zhnn�ÛíÆÀÀº»»ÑØØ�ðßqè6�p¸�TWW3�D£QqA8�¶RR^\"5±½½�Í�w¹\\\n�O���JÌÖëõ¢££�uGmmxþ��Ãö�ÎÕK ½H¥Rhmmeæâ��²J¥rollLä�WUU��%Éí¨¬D__��N§8À¬���üÉ4�¡�j�Ä��&»EH��ÅÄåkkkb�4�QlvûSú</ÜÒÓÓ£��Æ�Ò²2¾�6Ò2��EÅB\"�Àt$�H�XOÓ!A¨¼¼üp�KG�£¨¸��uùÐ��Y.//�&�\t555 ÍÄât)Mü°�Áb\"
ÍH\nX%æ�$ÍÏ{¢°Ì<»�34���·õ{½�§�ç��ue�[[[b���«/âÀJ2
\rf¾�ˬ¯¶3�EõÉîg�^��Ñ�$y´�Üd�©Ò¢HÌB¤¤V��f£qü�R��Eiø���sa8�����̱3��¥�aN7µ1�GV�H$�õõu|i�±J¬ym2óÕøóõy&»���Ãs��-Ø�æ�Ñ8�J§Ûس¬!�ù�!���ó©ñ�C�¯Å�Sü8|`CSS�¦¦¦��\rÐxÈ��VA�
�ÙNÉd�»»»pvªqU÷áá¡_~�pÝ�Î�àôT�§ßy]H��üü|6²ö@�YºÉÃEáØßßG(�»ÎïáÒo���~dÅõ�)�¼oú��Î�½°° dbç%S©�õA�·Ø£|#��³K$CôÄ!Ç{��{�\n:?66¶,À¯^»¶LÝ9SG�ÆA£T�ÿ±ª9��½�\rö¸�¼Oà�åÌsJÇGC'ØÒÒ\"2`ðO?3�~và-Ñ@KKK<�Ø�3�¯\\¹��þÞ¥KËdü÷yNð¨å�po6�¯ïZþ�xàÜ9Ô�\rÙ)]]] ¡�¤n÷�;r©�æ/�\r=¥?�A�\\sssøæ��ÏB2��öñÝ´�Õu-ò©>o_¸�7Ïö#I.á~(�åejÂþ�ÃÃ�Y<Õq�î޹㡦ºIé*�ܸ�¿ß�2�jÅ4�¸`<SøYIz³�ɾ·iù(�àQ�ÕËô�¾���üzþÏ��ÁÇd3ö²�êa£?\t��A*ümê��7Î�9ö�û_��¤wæ¢\nrÂxIEND®B`�";
var pan1 = win.add("panel", undefined, "选色");
pan1.alignChildren = "top";
pan1.orientation = "row";
var pan11 = pan1.add("panel", undefined, "CMYK四原色(中英文)");
pan11.alignChildren = "left";
pan11.spacing = 3;
var gi11 = pan11.add("group");
gi11.orientation = "row";
gi11.alignChildren = "left";
var rb113 = gi11.add("radiobutton", undefined, "无");
var rb111 = gi11.add("radiobutton", undefined, "全部");
rb111.value = true;
var rb112 = gi11.add("radiobutton", undefined, "自定");
var gi12 = pan11.add("group");
var cb121 = gi12.add("checkbox", undefined, "C");
var cb122 = gi12.add("checkbox", undefined, "M");
var cb123 = gi12.add("checkbox", undefined, "Y");
var cb124 = gi12.add("checkbox", undefined, "K");
var spacePan11 = pan11.add("panel", [0, 0, undefined, 2], "");
spacePan11.alignment = "fill";
var gi13 = pan11.add("group");
var cb131 = gi13.add("checkbox", undefined, "只列英文");
var cb132 = gi13.add("checkbox", undefined, "只列中文");
cb121.enabled = cb122.enabled = cb123.enabled = cb124.enabled = false;
cb121.value = cb122.value = cb123.value = cb124.value = true;
rb111.onClick = function () {
rb111.value == true;
cb121.value = cb122.value = cb123.value = cb124.value = cb131.enabled = cb132.enabled = true;
cb121.enabled = cb122.enabled = cb123.enabled = cb124.enabled = false;
};
rb112.onClick = function () {
rb112.value == true;
cb121.value = cb122.value = cb123.value = false;
cb124.value = true;
cb121.enabled = cb122.enabled = cb123.enabled = cb124.enabled = cb131.enabled = cb132.enabled = true;
};
rb113.onClick = function () {
rb111.value == true;
cb121.value = cb122.value = cb123.value = cb124.value = cb131.value = cb132.value = false;
cb121.enabled = cb122.enabled = cb123.enabled = cb124.enabled = cb131.enabled = cb132.enabled = false;
};
var pan12 = pan1.add("panel", undefined, "特别色");
pan12.spacing = 4.5;
var gi12 = pan12.add("group");
gi12.orientation = "row";
gi12.alignment = "left";
var rb121 = gi12.add("radiobutton", undefined, "无");
var rb122 = gi12.add("radiobutton", undefined, "全部");
rb122.value = true;
var cb1221 = pan12.add("checkbox", undefined, "简化PANTONE名称");
var spacePan12 = pan12.add("panel", [0, 0, undefined, 2], "");
spacePan12.alignment = "fill";
var st1221 = pan12.add("statictext", undefined, "(例:871 C 186 C ...)");
st1221.alignment = "right";
var pan2 = win.add("panel", undefined, "相关选项");
pan2.alignChildren = "fill";
var pan21 = pan2.add("panel", undefined, "排列方式");
var gi21 = pan21.add("group");
gi21.orientation = "row";
gi21.alignment = "left";
var rb211 = gi21.add("radiobutton", undefined, "一排");
rb211.value = true;
var rb212 = gi21.add("radiobutton", undefined, "两排");
var pan22 = pan2.add("panel", undefined, "位置");
var gi22 = pan22.add("group");
gi22.orientation = "row";
gi22.alignment = "left";
var rb221 = gi22.add("radiobutton", undefined, "置于屏幕正中");
rb221.value = true;
var rb222 = gi22.add("radiobutton", undefined, "置于页面左上角外");
var rb223 = gi22.add("radiobutton", undefined, "手动黏贴");
var pan23 = pan2.add("panel", undefined, "其他");
var gi23 = pan23.add("group");
gi23.orientation = "row";
gi23.alignment = "left";
var cb231 = gi23.add("checkbox", undefined, "选取状态");
cb231.value = true;
var cb232 = gi23.add("checkbox", undefined, "两者再编组");
cb232.value = true;
var cb233 = gi23.add("checkbox", undefined, "色号后附加油墨总数");
cb233.value = true;
var giEnd = win.add("group");
giEnd.alignment = "center";
var okBtn = giEnd.add("button", undefined, "运行", {
name: "ok"
});
var cancelBtn = giEnd.add("button", undefined, "取消", {
name: "cancel"
});
var spacePan2 = win.add("panel", [0, 0, undefined, 2], "");
var giSign = win.add("group");
giSign.spacing = 0;
giSign.alignment = "center";
var cpcImg = "�PNG\r\n�\n\rIHDR(��d×=�tEXtSoftwareAdobe ImageReadyqÉe<�ÄIDATxÚÌVËO�a���ÚÖ�Ù\n�ÑmÏCY¸\\l��yĤÜ�[IÆ�ÒxE��@à`D��!h4áe¤âÁ.^@\"¡
��8l�°õa#�Z�Å�åÛ¥�-���|Ùô{Ío~ó�ù\npÂ-+uâ^Û]�?�������G�Ç«§}Ï�Sö¶ã�;â~:;�çä�s6æ�g~�\t>f2�Ä�.ütW¯TsE�b¸°���DãÆ:�ý\"�ÞÚ\nãº�/\t��Îl�+++3¢�
Bð+�%pvv���7��¶Êª*(++SöíÆbð�÷�¾��X,Ö�{½i\t�iÏ4pgº\r�\"E��kû��ó¦¦ ïÃ�â��³X,¢»µõÈ�ÍÍÎÂG���£HD�&Ô74�L§[�áõÈ�E¬»i.;!��÷Þ$p©¶ÙØÛ��±Ð�Ot��¤¤¹�ÚZ@¦é~����ÍͺàÈ8��Û�0®»X6�¢ubZ¡p³PÛ<_ò�zoô@aßsLñÆ!ȦFøk2Ù�>�,°¸/ûûá\r²�hfN�©`w8´9L%���Áî�ý~å7��¯G\"�F5�6k¸B;,Zý0l��×\nVÝç��º.>é&ý)k�L&Ø��½WÓ�0��Y�ÒòrÐ[ãqM5\n����$É��㣣Ú�Ó¦@�=ÅæxSül�{hnÔÁ��À¥Ë��]:��dT0©ECÌD£QÈÏÏ×æH�¨³0Þïd÷Ï`AI�::Ò:Bö!m�±ý¬�Q���öÁKa\t¾-,(ãg$�ÿi/�8,�úÊz�cUÞÅ��Ô¡úU�îî��u¶¡i�^ô]ïÆ�(�||/nû,���Ç�õ:»C�P �� êP5é `¨¯õnËò¸æ�S�Ràp]D��8u��I�F��.�l�à¤è·\nÖ��\n¤¯Ç;É}�.m�û.�KËË�8�Á��óÊ�ÔB�··\t�ѯö1�ú�K£�©åT�Þli!\r\n8'�f�¥A��£�¯�ìY[-ðÌÏ�pWjV��¢â��Êû�d�êìv0�1̰ίÛmR_�f½>�¯�µ�e�k4�\rµ©�ìÒ4È�\"÷ð��©µêz%æ(µ�ÞBÀ�Ç}SÑÇct>AÕKýRϨxh�½&3zO�¥l 7w�'&××�ã�ó���£¤�1GO�Ì�{@§X¼¸Þ�\t(�£&ßNO�5fj?$\r��ò ä]�ç³2\\âb}�W��4�!uÇ6��+¡��°/z�,N¼ý�` �²Ö�ñºÈIEND®B`�";
var imgSign = giSign.add("image", undefined, cpcImg);
var stSign = giSign.add("statictext", undefined, "CPC中印 ");
var stSign2 = giSign.add("statictext", undefined, " by calvin530126");
okBtn.onClick = function () {
txt4C = txtSpot = "";
if (rb113.value == true && rb121.value == true) {
alert("请勿两种色号同时勾选'无'");
rb111.value = rb122.value = true;
return false;
} else {
if (rb111.value == true || rb112.value == true || rb122.value == true) {
actAbIndex = ab.getActiveArtboardIndex();
var abSize = ab[actAbIndex].artboardRect;
if (rb111.value == true || rb112.value == true) {
for4cInfo();
var all4ColorSum = 4;
var txt4cLen = Number(txt4C.contents.length);
if (cb121.value == false) {
all4ColorSum = all4ColorSum - 1;
if (txt4cLen == 20) {
var result = txt4C.contents.lastIndexOf("蓝色(C)");
for (i = result; i < (result + 5); i++) {
txt4C.textRange.characters[result].remove();
}
}
if (txt4cLen == 8) {
var result = txt4C.contents.lastIndexOf("蓝色");
for (i = result; i < (result + 2); i++) {
txt4C.textRange.characters[result].remove();
}
}
if (txt4cLen == 4) {
var result = txt4C.contents.lastIndexOf("C");
for (i = result; i < (result + 1); i++) {
txt4C.textRange.characters[result].remove();
}
}
}
if (cb122.value == false) {
all4ColorSum = all4ColorSum - 1;
if (txt4cLen == 20) {
var result = txt4C.contents.lastIndexOf("洋红(M)");
for (i = result; i < (result + 5); i++) {
txt4C.textRange.characters[result].remove();
}
}
if (txt4cLen == 8) {
var result = txt4C.contents.lastIndexOf("洋红");
for (i = result; i < (result + 2); i++) {
txt4C.textRange.characters[result].remove();
}
}
if (txt4cLen == 4) {
var result = txt4C.contents.lastIndexOf("M");
for (i = result; i < (result + 1); i++) {
txt4C.textRange.characters[result].remove();
}
}
}
if (cb123.value == false) {
all4ColorSum = all4ColorSum - 1;
if (txt4cLen == 20) {
var result = txt4C.contents.lastIndexOf("黄色(Y)");
for (i = result; i < (result + 5); i++) {
txt4C.textRange.characters[result].remove();
}
}
if (txt4cLen == 8) {
var result = txt4C.contents.lastIndexOf("黄色");
for (i = result; i < (result + 2); i++) {
txt4C.textRange.characters[result].remove();
}
}
if (txt4cLen == 4) {
var result = txt4C.contents.lastIndexOf("Y");
for (i = result; i < (result + 1); i++) {
txt4C.textRange.characters[result].remove();
}
}
}
if (cb124.value == false) {
all4ColorSum = all4ColorSum - 1;
if (txt4cLen == 20) {
var result = txt4C.contents.lastIndexOf("黑色(K)");
for (i = result; i < (result + 5); i++) {
txt4C.textRange.characters[result].remove();
}
}
if (txt4cLen == 8) {
var result = txt4C.contents.lastIndexOf("黑色");
for (i = result; i < (result + 2); i++) {
txt4C.textRange.characters[result].remove();
}
}
if (txt4cLen == 4) {
var result = txt4C.contents.lastIndexOf("K");
for (i = result; i < (result + 1); i++) {
txt4C.textRange.characters[result].remove();
}
}
}
}
if (rb122.value == true) {
createAction(actionStr1, set);
app.loadAction(f);
f.remove();
app.doScript(action1, set);
app.unloadAction(set, "");
forSpotColorInfo();
if (txtSpot == "") {
alert("此档案没有使用特别色");
}
}
if (rb113.value == true) {
all4ColorSum = 0;
}
if (rb121.value == true) {
arrSpotColor.length = 0;
}
var allColorSum = Number(arrSpotColor.length) + Number(all4ColorSum);
if (allColorSum != 0 && cb233.value == true) {
txtForAllColorSum = doc.textFrames.add();
txtForAllColorSum.stroked = false;
txtForAllColorSum.filled = true;
txtForAllColorSum.textRange.fillColor = doc.swatches[regName].color;
txtForAllColorSum.textRange.size = 10;
txtForAllColorSum.textRange.characterAttributes.textFont = app.textFonts.MicrosoftYaHei;
txtForAllColorSum.contents = "(共" + allColorSum + "色)";
}
if (rb122.value == true && txtSpot != "") {
if (rb211.value == true) {
txt4C.top = abSize[0] + txt4C.height;
}
if (rb212.value == true) {
txt4C.top = abSize[0] + txt4C.height + txtSpot.height;
txt4C.left = abSize[1];
}
} else {
if (rb122.value == false) {
txt4C.top = abSize[0] + txt4C.height;
txt4C.left = abSize[1];
}
}
if (txtSpot != null) {
if (rb211.value == true) {
if (txt4C == "") {
txtSpot.top = abSize[0] + txtSpot.height;
txtSpot.left = abSize[1];
} else {
if (txt4C != "") {
txtSpot.top = abSize[0] + txtSpot.height;
txtSpot.left = txt4C.width + abSize[1] + 2;
}
}
}
if (rb212.value == true) {
txtSpot.top = abSize[0] + txtSpot.height;
txtSpot.left = abSize[1];
}
}
if (cb233.value == true) {
if (rb211.value == true) {
txtForAllColorSum.top = abSize[0] + txtForAllColorSum.height;
if (rb113.value != true && rb121.value != true) {
txtForAllColorSum.left = txt4C.width + txtSpot.width + abSize[1] + 2;
}
if (rb113.value == true && txtSpot != "") {
txtForAllColorSum.left = txtSpot.width + abSize[1] + 2;
}
if (rb121.value == true && txt4C != "") {
txtForAllColorSum.left = txt4C.width + abSize[1] + 2;
}
} else {
if (rb212.value == true) {
if (rb113.value != true && rb121.value != true) {
txtForAllColorSum.top = abSize[0] + txtForAllColorSum.height;
txtForAllColorSum.left = txtSpot.width + abSize[1] + 2;
}
if (rb113.value == true && txtSpot != "") {
txtForAllColorSum.top = abSize[0] + txtForAllColorSum.height;
txtForAllColorSum.left = txtSpot.width + abSize[1] + 2;
}
if (rb121.value == true && txt4C != "") {
txtForAllColorSum.top = abSize[0] + txtForAllColorSum.height;
txtForAllColorSum.left = txt4C.width + abSize[1] + 2;
}
}
}
}
if (cb232.value == true) {
giAllTxt = doc.activeLayer.groupItems.add();
if (rb211.value == true || rb212.value == true) {
if (rb113.value != true && rb121.value != true) {
txt4C.move(giAllTxt, ElementPlacement.INSIDE);
txtSpot.move(giAllTxt, ElementPlacement.INSIDE);
}
if (rb113.value == true && txtSpot != "") {
txtSpot.move(giAllTxt, ElementPlacement.INSIDE);
}
if (rb121.value == true && txt4C != "") {
txt4C.move(giAllTxt, ElementPlacement.INSIDE);
}
}
if (cb233.value == true) {
txtForAllColorSum.move(giAllTxt, ElementPlacement.INSIDE);
}
}
if (txt4C != null) {
txt4C.selected = true;
}
if (txtSpot != null) {
txtSpot.selected = true;
}
if (txtForAllColorSum != null) {
txtForAllColorSum.selected = true;
}
if (rb221.value == true) {
if (txt4C != null) {
txt4C.selected = true;
}
if (txtSpot != null) {
txtSpot.selected = true;
}
app.executeMenuCommand("cut");
app.executeMenuCommand("paste");
if (cb231.value == false) {
doc.selection = null;
}
}
if (rb223.value == true) {
if (txt4C != "") {
txt4C.selected = true;
}
if (txtSpot != "") {
txtSpot.selected = true;
}
app.executeMenuCommand("cut");
}
}
}
win.close();
};
win.center();
win.show();
function createAction(act, set) {
f = new File("~/Desktop/" + set + ".aia");
f.open("w");
f.write(act);
f.close();
f.hidden = true;
}
function for4cInfo() {
txt4C = lay.textFrames.add();
txt4C.fillColor = true;
txt4C.strokeColor = false;
txt4C.textRange.size = 10;
if (cb131.value == false && cb132.value == false) {
txt4C.contents = "蓝色(C)洋红(M)黄色(Y)黑色(K)";
} else if (cb131.value == true && cb132.value == true) {
txt4C.contents = "蓝色(C)洋红(M)黄色(Y)黑色(K)";
} else if (cb131.value == true && cb132.value == false) {
txt4C.contents = "CMYK";
} else {
if (cb131.value == false && cb132.value == true) {
txt4C.contents = "蓝色洋红黄色黑色";
}
}
var cha = txt4C.textRange.characters.length;
txt4C.textRange.characterAttributes.textFont = app.textFonts[textFonts.name = "MicrosoftYaHei"];
var j = 0;
var cd = 0;
for (var i = 0; i < cha; i += 1) {
txt4C.textRange.characters[i].characterAttributes.fillColor = colAll[j];
cd++;
if (cb131.value == false && cb132.value == false && (cd % 5) == 0) {
j++;
} else if (cb131.value == true && cb132.value == true && (cd % 5) == 0) {
j++;
} else if (cb131.value == true && cb132.value == false && (cd % 1) == 0) {
j++;
} else {
if (cb131.value == false && cb132.value == true && (cd % 2) == 0) {
j++;
}
}
}
}
function forSpotColorInfo() {
var col = doc.swatches;
var colLen = col.length;
for (var i = 0; i < colLen; i += 1) {
if (col[i].color.typename == "SpotColor" && col[i].color.spot.colorType == ColorModel.SPOT) {
arrSpotColor.push(i)
}
}
if (arrSpotColor.length != 0) {
txtSpot = lay.textFrames.add();
txtSpot.textRange.size = 10;
txtSpot.textRange.characterAttributes.textFont = app.textFonts[textFonts.name = "MicrosoftYaHei"];
for (var j = 0; j < arrSpotColor.length; j += 1) {
var num = eval(arrSpotColor[j]);
if (col[num].name.search(/PANTONE/i) != -1 && cb1221.value == true) {
spotnameTem = col[num].name.slice(7, col[num].name.length);
} else {
spotnameTem = col[num].name;
}
txtSpot.textRange.characters.add(spotnameTem);
var txtLength = txtSpot.contents.length;
for (i = txtLength - spotnameTem.length; i < txtLength; i++) {
txtSpot.textRange.characters[i].characterAttributes.fillColor = col[num].color;
}
}
}
}
合理的脚本代码可以有效的提高工作效率,减少重复劳动。