{
"window": {
"title": "AddShape",
"author": "jialan75",
"date": "2022年5月14日08:57:43"
},
"variable": {
"artboard_w": "画板宽度",
"artboard_h": "画板高度",
"artboard_left": "画板左边",
"artboard_bottom": "画板底部",
"artboard_right": "画板右边",
"artboard_top": "画板顶部",
"artboard_index": "当前页面下标",
"artboard_length": "总页数",
"artboard_back_front": "正面或者反面",
"this_w": "当前宽度",
"this_h": "当前高度",
"ctp_w": "CTP宽度 暂时不可用",
"ctp_h": "CTP高度 暂时不可用",
"ctp_y": "CTP咬口 暂时不可用",
"name": "当前文件名",
"name_no_suffix": "无后缀的文件名",
"parent": "父路径",
"path": "全路径",
"year": "年份",
"year2": "年份保留个位和十位",
"month": "月份",
"month2": "月份保持2位数不够补0",
"day": "日",
"day2": "日保持2位数不够补0",
"index": "当前页面下标",
"input_str": "弹窗输入的内容",
"jxcd": "脚线长度",
"jxjb": "脚线距边"
},
"添加图形": [
{
"name": "文字 年月日",
"type": "text",
"content": "{{year}}-{{month2}}-{{day2}}",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "center",
"rotate": 0,
"fillColor": "regcolor",
"x": "{{artboard_left}}+{{artboard_w}}/2-6*{{pt}}",
"y": "{{artboard_bottom}}+0.2*{{pt}}+{{this_h}}"
},
{
"name": "文字C",
"type": "text",
"content": "C",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "center",
"rotate": 0,
"fillColor": "100-0-0-0",
"x": "{{artboard_left}}+{{artboard_w}}/2+6*{{pt}}",
"y": "{{artboard_bottom}}+0.2*{{pt}}+{{this_h}}"
},
{
"name": "文字M",
"type": "text",
"content": "M",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "center",
"rotate": 0,
"fillColor": "0-100-0-0",
"x": "{{artboard_left}}+{{artboard_w}}/2+8*{{pt}}",
"y": "{{artboard_bottom}}+0.2*{{pt}}+{{this_h}}"
},
{
"name": "文字Y",
"type": "text",
"content": "Y",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "center",
"rotate": 0,
"fillColor": "0-0-100-0",
"x": "{{artboard_left}}+{{artboard_w}}/2+10*{{pt}}",
"y": "{{artboard_bottom}}+0.2*{{pt}}+{{this_h}}"
},
{
"name": "文字K",
"type": "text",
"content": "K",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "center",
"rotate": 0,
"fillColor": "0-0-0-100",
"x": "{{artboard_left}}+{{artboard_w}}/2+12*{{pt}}",
"y": "{{artboard_bottom}}+0.2*{{pt}}+{{this_h}}"
},
{
"name": "文字 无后缀的文件名",
"type": "text",
"content": "{{name_no_suffix}}",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "regcolor",
"x": "{{artboard_left}}+{{artboard_w}}/2+20*{{pt}}",
"y": "{{artboard_bottom}}+0.2*{{pt}}+{{this_h}}"
},
{
"name": "文字 [2-1]正面:无后缀文件名",
"type": "text",
"content": "[{{artboard_length}}-{{artboard_index}}]{{artboard_back_front}}:{{name_no_suffix}}",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": false,
"alignment": "left",
"rotate": 0,
"fillColor": "regcolor",
"x": "{{artboard_left}}+8*{{pt}}",
"y": "{{artboard_bottom}}+0.2*{{pt}}+{{this_h}}"
},
{
"name": "文字 [2-1]正面:无后缀文件名",
"type": "text",
"content": "[{{artboard_length}}-{{artboard_index}}]{{artboard_back_front}}:{{name_no_suffix}}",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 90,
"fillColor": "regcolor",
"x": "{{artboard_left}}",
"y": "{{artboard_bottom}}+{{artboard_h}}/2+3*{{pt}}+{{this_h}}"
},
{
"name": "文字 1种",
"type": "text",
"content": "{{input_str}}种",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 90,
"fillColor": "regcolor",
"x": "{{artboard_left}}",
"y": "{{artboard_top}}-8*{{pt}}"
},
{
"name": "文字 1种",
"type": "text",
"content": "{{input_str}}种",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "regcolor",
"x": "{{artboard_left}}+8*{{pt}}",
"y": "{{artboard_top}}"
},
{
"name": "文字 [2-1]正面:无后缀文件名",
"type": "text",
"content": "[{{artboard_length}}-{{artboard_index}}]{{artboard_back_front}}:{{name_no_suffix}}",
"fontSize": 6,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 90,
"fillColor": "regcolor",
"x": "{{artboard_right}}-{{this_w}}",
"y": "{{artboard_bottom}}+{{artboard_h}}/2+3*{{pt}}+{{this_h}}"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "100-0-0-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*10",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-100",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色100",
"type": "text",
"content": "100",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-0",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*10+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*9",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-90",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色90",
"type": "text",
"content": "90",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-0",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*9+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*8",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-80",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色80",
"type": "text",
"content": "80",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-0",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*8+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*7",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-70",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色70",
"type": "text",
"content": "70",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-0",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*7+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*6",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-60",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色60",
"type": "text",
"content": "60",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-0",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*6+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*5",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-50",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色50",
"type": "text",
"content": "50",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-0",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*5+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*4",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-40",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色40",
"type": "text",
"content": "40",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-0",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*4+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*3",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-30",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色30",
"type": "text",
"content": "30",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-100",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*3+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*2",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-20",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色20",
"type": "text",
"content": "20",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-100",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*2+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 黑色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*1",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-0-10",
"strokeColor": "nocolor"
},
{
"name": "文字 黑色10",
"type": "text",
"content": "10",
"fontSize": 3,
"fontName": "微软雅黑",
"outline": true,
"alignment": "left",
"rotate": 0,
"fillColor": "0-0-0-100",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*1+(3*{{pt}}-{{this_w}})/2",
"y": "{{artboard_top}}-(3*{{pt}}-{{this_h}})/2"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*20",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-100-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*19",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-90-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*18",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-80-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*17",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-70-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*16",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-60-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*15",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-50-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*14",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-40-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*13",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-30-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*12",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-20-0",
"strokeColor": "nocolor"
},
{
"name": "矩形 青色色块",
"type": "rect",
"x": "{{artboard_left}}+11*{{pt}}+3*{{pt}}*11",
"y": "{{artboard_top}}",
"w": "3*{{pt}}",
"h": "3*{{pt}}",
"expand": 0,
"strokeWidth": "0",
"fillColor": "0-0-10-0",
"strokeColor": "nocolor"
},
{
"name": "图片",
"type": "picture",
"path": "C:/Users/Administrator/Desktop/img.png",
"x": "{{artboard_left}}+({{artboard_w}}-{{this_w}})/2",
"y": "{{artboard_bottom}}+{{this_h}}+15*{{pt}}",
"w": "{{this_w}}",
"h": "{{this_h}}",
"embed": true
},
{
"name": "PDF文件 第一页",
"type": "pdf",
"path": "C:/Users/Administrator/Desktop/未标题-7.pdf",
"x": "{{artboard_right}}-{{this_w}}-8*{{pt}}",
"y": "{{artboard_top}}",
"w": "{{this_w}}",
"h": "{{this_h}}",
"index": 1,
"embed": true
},
{
"name": "线条 ",
"type": "line",
"x1": "{{artboard_left}}",
"y1": "{{artboard_top}}",
"x2": "{{artboard_right}}",
"y2": "{{artboard_bottom}}",
"strokeWidth": "2*{{pt}}",
"strokeColor": "PANTONE 485 C-0-100-100-0-100"
},
{
"name": "线条 ",
"type": "line",
"x1": "{{artboard_left}}",
"y1": "{{artboard_bottom}}",
"x2": "{{artboard_right}}",
"y2": "{{artboard_top}}",
"strokeWidth": "2*{{pt}}",
"strokeColor": "PANTONE 485 C-0-100-100-0-100"
},
{
"name": "椭圆",
"type": "ellipse",
"x": "{{artboard_left}}+{{artboard_w}}/2-50*{{pt}}",
"y": "{{artboard_bottom}}+{{artboard_h}}/2+50*{{pt}}",
"w": "100*{{pt}}",
"h": "100*{{pt}}",
"expand": 0,
"strokeWidth": "0.5*{{pt}}",
"fillColor": "nocolor",
"strokeColor": "PANTONE 485 C-0-100-100-0-100"
},
{
"name": "椭圆",
"type": "ellipse",
"x": "{{artboard_left}}+{{artboard_w}}/2-50*{{pt}}",
"y": "{{artboard_bottom}}+{{artboard_h}}/2+50*{{pt}}",
"w": "100*{{pt}}",
"h": "100*{{pt}}",
"expand": "-3*{{pt}}",
"strokeWidth": "0.5*{{pt}}",
"fillColor": "nocolor",
"strokeColor": "PANTONE 485 C-0-100-100-0-100"
},
{
"name": "左边的脚线",
"type": "line",
"x1": "{{artboard_left}}",
"y1": "{{artboard_bottom}}+{{jxcd}}",
"x2": "{{artboard_left}}+{{jxcd}}",
"y2": "{{artboard_bottom}}+{{jxcd}}",
"strokeWidth": "0.1*{{pt}}",
"strokeColor": "regcolor"
},
{
"name": "左边的脚线",
"type": "line",
"x1": "{{artboard_left}}",
"y1": "{{artboard_bottom}}+{{jxcd}}+{{jxjb}}",
"x2": "{{artboard_left}}+{{jxcd}}",
"y2": "{{artboard_bottom}}+{{jxcd}}+{{jxjb}}",
"strokeWidth": "0.1*{{pt}}",
"strokeColor": "regcolor"
},
{
"name": "左边的脚线",
"type": "line",
"x1": "{{artboard_left}}+{{jxcd}}+{{jxjb}}",
"y1": "{{artboard_bottom}}",
"x2": "{{artboard_left}}+{{jxcd}}+{{jxjb}}",
"y2": "{{artboard_bottom}}+{{jxcd}}",
"strokeWidth": "0.1*{{pt}}",
"strokeColor": "regcolor"
},
{
"name": "左边的脚线",
"type": "line",
"x1": "{{artboard_left}}+{{jxcd}}",
"y1": "{{artboard_bottom}}",
"x2": "{{artboard_left}}+{{jxcd}}",
"y2": "{{artboard_bottom}}+{{jxcd}}",
"strokeWidth": "0.1*{{pt}}",
"strokeColor": "regcolor"
},
{
"name": "右边的脚线",
"type": "line",
"x1": "{{artboard_right}}",
"y1": "{{artboard_bottom}}+{{jxcd}}",
"x2": "{{artboard_right}}-{{jxcd}}",
"y2": "{{artboard_bottom}}+{{jxcd}}",
"strokeWidth": "0.1*{{pt}}",
"strokeColor": "regcolor"
},
{
"name": "右边的脚线",
"type": "line",
"x1": "{{artboard_right}}",
"y1": "{{artboard_bottom}}+{{jxcd}}+{{jxjb}}",
"x2": "{{artboard_right}}-{{jxcd}}",
"y2": "{{artboard_bottom}}+{{jxcd}}+{{jxjb}}",
"strokeWidth": "0.1*{{pt}}",
"strokeColor": "regcolor"
},
{
"name": "右边的脚线",
"type": "line",
"x1": "{{artboard_right}}-{{jxcd}}",
"y1": "{{artboard_bottom}}",
"x2": "{{artboard_right}}-{{jxcd}}",
"y2": "{{artboard_bottom}}+{{jxcd}}",
"strokeWidth": "0.1*{{pt}}",
"strokeColor": "regcolor"
},
{
"name": "右边的脚线",
"type": "line",
"x1": "{{artboard_right}}-{{jxcd}}-{{jxjb}}",
"y1": "{{artboard_bottom}}",
"x2": "{{artboard_right}}-{{jxcd}}-{{jxjb}}",
"y2": "{{artboard_bottom}}+{{jxcd}}",
"strokeWidth": "0.1*{{pt}}",
"strokeColor": "regcolor"
}
]
}
var SET = new LoadSetting();
var input_str = prompt("请输入","")
work('添加图形')
function work(title) {
create_layer('info');
var json_path = "C:\\Users\\Administrator\\Downloads\\11343529_g\\tencentcos\\tencentcos\\src\\main\\resources\\aijsAddAll\\配置.json"
eval('var data = ' + new Txt(json_path).read());
for (var i = 0; i < data[title].length; i++) {
try{
var obj = data[title][i];
if (obj.type === SET.types.text) {
new Text(obj).work();
} else if (obj.type === SET.types.picture) {
new Picture(obj).work();
} else if (obj.type === SET.types.pdf) {
new Pdf(obj).work();
} else if (obj.type === SET.types.rect) {
new Rect(obj).work();
} else if (obj.type === SET.types.line) {
new Line(obj).work();
} else if (obj.type === SET.types.ellipse) {
new Ellipse(obj).work();
}
}catch (e) {
}
}
}
function LoadSetting() {
this.alignment = {
"center": Justification.CENTER,
"left": Justification.LEFT,
"right": Justification.RIGHT,
}
this.getColor = function (color) {
var colors = {
"white": create_color_plus("0-0-0-0"),
"black": create_color_plus("0-0-0-100"),
"cyan": create_color_plus("100-0-0-0"),
"yellow": create_color_plus("0-0-100-0"),
"magenta": create_color_plus("0-100-0-0"),
"nocolor": create_color_plus('nocolor'),
"regcolor": create_color_plus('regcolor')
}
if (colors[color] != undefined) {
return colors[color];
} else {
return create_color_plus(color);
}
}
this.fontNames = {
"微软雅黑": "MicrosoftYaHei"
}
this.types = {
"text": "text",
"picture": "picture",
"pdf": "pdf",
"rect": "rect",
"line": "line",
"ellipse": "ellipse",
}
return this;
}
function Text(data) {
this.content = data.content;
this.fontSize = data.fontSize;
this.fontName = SET.fontNames[data.fontName];
this.outline = data.outline;
this.rotate = data.rotate;
this.fillColor = SET.getColor(data.fillColor);
this.x = data.x;
this.y = data.y;
this.alignment = SET.alignment[data.alignment];
this.work = function () {
var doc = app.activeDocument;
for (var i = 0; i < doc.artboards.length; i++) {
var textRef = doc.textFrames.add();
textRef.contents = replace_str(this.content,new MyData(new Artboard(i), ""));
textRef.textRange.paragraphAttributes.justification = this.alignment;
textRef.textRange.characterAttributes.fillColor = this.fillColor;
var text_font = null;
try {
text_font = textFonts.getByName(this.fontName)
} catch (e) {
try {
text_font = textFonts[font_name]
} catch (e) {
text_font = textFonts.getByName('MicrosoftYaHei')
}
}
textRef.textRange.characterAttributes.textFont = text_font;
textRef.textRange.characterAttributes.size = this.fontSize;
textRef.rotate(this.rotate)
if (this.outline) textRef = textRef.createOutline();
textRef.left = calculation(replace_str(this.x.toString() + "", new MyData(new Artboard(i), textRef)));
textRef.top = calculation(replace_str(this.y.toString() + "", new MyData(new Artboard(i), textRef)));
}
}
}
function Picture(data) {
this.path = data.path;
this.x = data.x;
this.y = data.y;
this.w = data.w;
this.h = data.h;
this.embed = data.embed;
this.work = function () {
var aFile = File(this.path);
if (aFile.exists) {
var doc = app.activeDocument;
for (var i = 0; i <doc.artboards.length ; i++) {
var myPlacedItem = doc.placedItems.add();
myPlacedItem.file = aFile;
var x =calculation(replace_str(this.x.toString(),new MyData(new Artboard(i), doc.selection[0])))
var y = calculation(replace_str(this.y.toString(),new MyData(new Artboard(i), doc.selection[0])))
myPlacedItem.position = Array(x, y);
if (this.embed) myPlacedItem.embed();
if (this.w != 0 && this.h != 0) {
var w = calculation(replace_str(this.w.toString(),new MyData(new Artboard(i),doc.selection[0])))
var h = calculation(replace_str(this.h.toString(),new MyData(new Artboard(i),doc.selection[0])))
doc.selection[0].width = w;
doc.selection[0].height = h;
}
}
} else {
alert(this.path+">>>路径不存在");
}
}
}
function Pdf(data) {
this.path = data.path;
this.index = data.index;
this.x = data.x;
this.y = data.y;
this.w = data.w;
this.h = data.h;
this.embed = data.embed;
this.work = function () {
var aFile = File(this.path);
if (!aFile.exists) {
alert(this.path+">>>路径不存在");
} else {
var doc = app.activeDocument;
for (var i = 0; i <doc.artboards.length ; i++) {
var pdfOptions = app.preferences.PDFFileOptions;
pdfOptions.pageToOpen = this.index;//此处选择置入页码 貌似低版本不支持这个选项
var myPlacedItem = doc.placedItems.add();
myPlacedItem.file = aFile;
var x =calculation(replace_str(this.x.toString(),new MyData(new Artboard(i), doc.selection[0])))
var y = calculation(replace_str(this.y.toString(),new MyData(new Artboard(i), doc.selection[0])))
myPlacedItem.position = Array(x, y);
if (this.embed) myPlacedItem.embed();
if (this.w != 0 && this.h != 0) {
var w = calculation(replace_str(this.w.toString(),new MyData(new Artboard(i),doc.selection[0])))
var h = calculation(replace_str(this.h.toString(),new MyData(new Artboard(i),doc.selection[0])))
doc.selection[0].width = w;
doc.selection[0].height = h;
}
}
}
}
}
function Rect(data) {
this.x = data.x;
this.y = data.y;
this.w = data.w;
this.h = data.h;
this.strokeColor = SET.getColor(data.strokeColor);
this.strokeWidth = data.strokeWidth;
this.fillColor = SET.getColor(data.fillColor);
this.expand = data.expand;
this.work = function () {
var doc = app.activeDocument;
for (var i = 0; i < doc.artboards.length; i++) {
var x =calculation(replace_str(this.x.toString(),new MyData(new Artboard(i), "")))
var y = calculation(replace_str(this.y.toString(),new MyData(new Artboard(i), "")))
var w = calculation(replace_str(this.w.toString(),new MyData(new Artboard(i), "")))
var h = calculation(replace_str(this.h.toString(),new MyData(new Artboard(i), "")))
var strokeWidth = calculation(replace_str(this.strokeWidth.toString(),new MyData(new Artboard(i), "")))
var expand = calculation(replace_str(this.expand.toString(),new MyData(new Artboard(i), "")))
var rect = doc.pathItems.rectangle(y + expand, x - expand, w + expand * 2, h + expand * 2);
if (this.strokeColor != undefined) {
rect.stroked = true;
rect.strokeColor = this.strokeColor;
rect.strokeWidth = strokeWidth;
}
if (this.fillColor != undefined) {
rect.fillColor = this.fillColor;
}
}
}
}
function Line(data) {
this.x1 = data.x1;
this.y1 = data.y1;
this.x2 = data.x2;
this.y2 = data.y2;
this.strokeColor = SET.getColor(data.strokeColor);
this.strokeWidth = data.strokeWidth;
this.work = function () {
var doc = app.activeDocument;
for (var i = 0; i < doc.artboards.length; i++) {
var line = doc.pathItems.add();
var x1 =calculation(replace_str(this.x1.toString(),new MyData(new Artboard(i), "")))
var y1 = calculation(replace_str(this.y1.toString(),new MyData(new Artboard(i), "")))
var x2 =calculation(replace_str(this.x2.toString(),new MyData(new Artboard(i), "")))
var y2 = calculation(replace_str(this.y2.toString(),new MyData(new Artboard(i), "")))
var strokeWidth = calculation(replace_str(this.strokeWidth.toString(),new MyData(new Artboard(i), "")))
line.setEntirePath([[x1, y1], [x2, y2]]);
line.stroked = true;
line.strokeWidth = strokeWidth;
line.strokeColor = this.strokeColor;
line.fillColor = SET.getColor("nocolor");
}
}
}
function Ellipse(data) {
this.x = data.x;
this.y = data.y;
this.w = data.w;
this.h = data.h;
this.strokeColor = SET.getColor(data.strokeColor);
this.strokeWidth = data.strokeWidth;
this.fillColor = SET.getColor(data.fillColor);
this.expand = data.expand;
this.work = function () {
var doc = app.activeDocument;
for (var i = 0; i < doc.artboards.length; i++) {
var x =calculation(replace_str(this.x.toString(),new MyData(new Artboard(i), "")))
var y = calculation(replace_str(this.y.toString(),new MyData(new Artboard(i), "")))
var w = calculation(replace_str(this.w.toString(),new MyData(new Artboard(i), "")))
var h = calculation(replace_str(this.h.toString(),new MyData(new Artboard(i), "")))
var strokeWidth = calculation(replace_str(this.strokeWidth.toString(),new MyData(new Artboard(i), "")))
var expand = calculation(replace_str(this.expand.toString(),new MyData(new Artboard(i), "")))
var ellipse = doc.pathItems.ellipse(y + expand, x - expand, w + expand * 2, h + expand * 2);;
if (this.strokeColor != undefined) {
ellipse.stroked = true;
ellipse.strokeColor = this.strokeColor;
ellipse.strokeWidth = strokeWidth;
}
if (this.fillColor != undefined) {
ellipse.fillColor = this.fillColor;
}
}
}
}
function create_color_plus(str) {
var doc = app.activeDocument;
/**
* 支持4种格式
* 意思依次是:获取无色
* var color = create_color("nocolor");
* 意思依次是:获取注册色
* var color = create_color_plus("regcolor");
* 意思依次是:C值,M值,Y值,K值
* var color = create_color("0-0-0-100");
* 意思依次是:专色名称,C值,M值,Y值,K值,专色百分比
* var color = create_color("PANTONE 485 C-0-100-100-0-100");
* 意思依次是:专色名称,C值,M值,Y值,K值,专色百分比
* var color = create_color("cut-100-0-0-0-100");
*/
if (str.indexOf("-") == -1) {
if (str == 'nocolor') return new NoColor();
if (str == 'regcolor') {
var newSpot = doc.swatches; // 寻找注册色代码段
for (var i = 0; i < newSpot.length; i++) {
var swatch = doc.swatches[i];
if (swatch.color == '[SpotColor]') {
var spot = swatch.color.spot;
var colorType = spot.colorType;
if (colorType.toString() == "ColorModel.REGISTRATION") {
index = i;
}
} else {
continue;
}
}
return doc.swatches[index].color;
}
} else {
var arr = str.split("-");
if (arr.length == 4) {
var cmykColor = new CMYKColor();//创建颜色变量
cmykColor.cyan = Number(arr[0]);//设置颜色的值
cmykColor.magenta = Number(arr[1]);//设置颜色的值
cmykColor.yellow = Number(arr[2]);//设置颜色的值
cmykColor.black = Number(arr[3]);//设置颜色的值
return cmykColor;
} else if (arr.length == 6) {
var newSpot = undefined;
try {
newSpot = doc.spots.getByName(arr[0]);
} catch (e) {
newSpot = doc.spots.add();
}
newSpot.name = arr[0];
newSpot.colorType = ColorModel.SPOT;
var cmykColor = new CMYKColor();//创建颜色变量
cmykColor.cyan = Number(arr[1]);//设置颜色的值
cmykColor.magenta = Number(arr[2]);//设置颜色的值
cmykColor.yellow = Number(arr[3]);//设置颜色的值
cmykColor.black = Number(arr[4]);//设置颜色的值
newSpot.color = cmykColor;
var newSpotColor = new SpotColor();
newSpotColor.spot = newSpot;
newSpotColor.tint = Number(arr[5]);
return newSpotColor;
}
}
}
function Artboard(index) {
var doc = app.activeDocument;
var pt = 72 / 25.4;
/**
* index 下标 (非必填 默认当前画板)
* 画板类用于获取画板的属性
* 宽度,高度,坐标(上下左右垂直中,水平中),简单的信息
*
* 例子
* artboard = Artboard()
* artboard = Artboard(0)
* 打印信息
* alert(artboard.info)
*/
index = index == undefined ? doc.artboards.getActiveArtboardIndex() : index
var abBounds = doc.artboards[index].artboardRect;
this.width = abBounds[2] - abBounds[0];
this.height = abBounds[1] - abBounds[3];
this.left = abBounds[0];
this.top = abBounds[1];
this.bottom = abBounds[3];
this.right = abBounds[2];
this.centerX = this.left + this.width / 2;
this.centerY = this.bottom + this.height / 2;
this.artboard = doc.artboards[index];
this.abBounds = abBounds;
this.index = index;
this.length = doc.artboards.length;
this.info = '当前是第' + index + '个页面\n页面尺寸为' + this.width / pt + 'x' + this.height / pt + ' mm'
return this;
}
function Txt(path) {
this.path = path;
this.read = function () {
try {
var f = new File(this.path);//文件位置
f.open('r');
var txt = f.read();
f.close();
return txt;
} catch (e) {
return '';
}
}
}
function MyData(artboard, that) {
var pt = 72/25.4;
var time = new Time();
this.artboard = {
w: artboard.width,
h: artboard.height,
left: artboard.left,
top: artboard.top,
right: artboard.right,
bottom: artboard.bottom,
index: artboard.index+1,
length: artboard.length,
};
this.that = {
w: that.width,
h: that.height,
};
this.name = get_name();
this.name_no_suffix = get_name_no_suffix();
this.parent = get_parent();
this.path = get_path();
this.time = {
year: time.year,
year2: time.year2,
month: time.month,
month2: time.month2,
day: time.day,
day2: time.day2,
};
this.ctp={
w:"760",
h:"605",
y:"45"
};
this.input_str=input_str;
this.jiaoxian = {
"jxjb":2*pt,
"jxcd":3*pt
}
}
function Time() {
var myDate = new Date();
this.month = myDate.getMonth() + 1;
this.day = myDate.getDate();
this.year = myDate.getFullYear();
this.month2 = str2(this.month + "");
this.day2 = str2(this.day + "");
this.year2 = str2(this.year + "");
}
function str2(str) {
str = "00" + str;
return str.substring(str.length - 2, str.length);
}
function get_path() {
var doc = app.activeDocument;
return decodeURI(doc.fullName);
}
function get_parent() {
var doc = app.activeDocument;
/**
* 获取父路径
* 返回 C:\Users\Administrator\Desktop
*/
return decodeURI(doc.fullName.parent);
}
function get_name() {
var doc = app.activeDocument;
/**
* 获取文件名
* 返回 hd1024.ai(也有可能 hd1024.pdf | hd1024.eps)
*/
return decodeURI(doc.fullName.name);
}
function get_name_no_suffix() {
var doc = app.activeDocument;
/**
* 获取文件名 无后缀
* 返回 hd1024
*/
n = decodeURI(doc.fullName.name);
return n.substring(0, n.lastIndexOf('.'));
}
function calculation(str) {
str += "+0";
return eval(str);
}
function create_layer(layer_name) {
var doc = app.activeDocument;
/**
* layer_name 图层名称 (非必填 默认 layer)
* 新建图层
* 如果图层已经存在就返回该图层并且激活该图层
*
* 例子
* create_layer()
* create_layer('图层名称')
*/
try{
return doc.layers.getByName(layer_name)
}catch(e){
layer_name = is_empty(layer_name) ? 'layer' : layer_name;
layer_ = doc.layers.add();
layer_.name = layer_name;
return layer_;
}
}
function is_empty(obj) {
/**
* 判断是不是空
*/
return obj == undefined || obj == '';
}
function replace_str(str, data) {
var pt = 72/25.4;
for (var i = 0; i < 4; i++) {
str = str.replace('{{artboard_w}}', data.artboard.w);
str = str.replace('{{artboard_h}}', data.artboard.h);
str = str.replace('{{artboard_left}}', data.artboard.left);
str = str.replace('{{artboard_bottom}}', data.artboard.bottom);
str = str.replace('{{artboard_right}}', data.artboard.right);
str = str.replace('{{artboard_top}}', data.artboard.top);
str = str.replace('{{artboard_length}}', data.artboard.length);
str = str.replace('{{artboard_index}}', data.artboard.index);
if(data.artboard.index%2==1){
str = str.replace('{{artboard_back_front}}', '正面');
}else{
str = str.replace('{{artboard_back_front}}', '反面');
}
str = str.replace('{{this_w}}', data.that.w);
str = str.replace('{{this_h}}', data.that.h);
str = str.replace('{{ctp_w}}', data.ctp.w);
str = str.replace('{{ctp_h}}', data.ctp.h);
str = str.replace('{{ctp_y}}', data.ctp.y);
str = str.replace('{{name}}', data.name);
str = str.replace('{{name_no_suffix}}', data.name_no_suffix);
str = str.replace('{{parent}}', data.parent);
str = str.replace('{{path}}', data.path);
str = str.replace('{{year}}', data.time.year);
str = str.replace('{{year2}}', data.time.year2);
str = str.replace('{{month}}', data.time.month);
str = str.replace('{{month2}}', data.time.month2);
str = str.replace('{{day}}', data.time.day);
str = str.replace('{{day2}}', data.time.day2);
str = str.replace('{{pt}}', pt);
str = str.replace('{{input_str}}', data.input_str);
str = str.replace('{{jxjb}}', data.jiaoxian.jxjb);
str = str.replace('{{jxcd}}', data.jiaoxian.jxcd);
}
return str;
}