论坛帮助 |
社区圈子 |
日历事件 |
2019-05-25, 14:32 | #1 | ||
|
|||
java爱好者
等级: 六袋长老
|
var infoGroup = doc.groupItems.add(); var pt=72/25.4; var sel=doc.selection; var s=sel[0]; var str = prompt("横?竖?", ""); var col=parseFloat(str.split(" ")[0]); var row=parseFloat(str.split(" ")[1]); if(!isNumber(col)){ alert("列数有问题!"); }else{ if(!isNumber(row)){ alert("行数有问题!"); } } if(isNumber(row)&&isNumber(col)){ var space=parseFloat(str.split(" ")[2]); if(isNumber(space)){ space=0; } /*获取 各种各样的信息 脚线 出血 坐标 尺寸 行数 列数 拼完后的 尺寸 咬口信息 */ var imp=new im(col,row,space,s); imp.s.selected=false; //取消选中 imposs(imp);//拼版 addLines(imp);//添加脚线 addText(imp.toString(),"MicrosoftYaHei",5.5,imp.left+6*pt,imp.top-imp.height);//添加文字 addArtboard(infoGroup);//页面适合脚线 s.remove();//删除选中的图形 } function isNumber(str){ if("0123456789".indexOf(str)==-1){ return false; } return true; } //添加文字 function addText(contens,font,fontSize,fontLeft,fontTop){ //内容 字体 字号 坐标x 坐标y var pt=72/25.4; var t1 = infoGroup.textFrames.add(); t1.contents=contens; t1.textRange.characterAttributes.size=fontSize; t1.textRange.characterAttributes.textFont = textFonts.getByName(font); t1.left=fontLeft; t1.top=fontTop+t1.height+0.2*pt; } //拼版 function imposs(imp){ for(var i=0;i<imp.col;i++){ for(var j=0;j<imp.row;j++){ var sl=imp.s.duplicate(); sl.left=imp.jiaoxian+imp.chuxue+imp.s.left+imp.width*i+imp.space*i; sl.top=imp.jiaoxian+imp.chuxue+imp.s.top+imp.height*j+imp.space*j; } } } //拼版信息类 function im(col,row,space,s){ var pt=72/25.4; this.jiaoxian=3*pt; this.chuxue=2*pt; this.left=parseFloat(s.geometricBounds[0]); this.top=parseFloat(s.geometricBounds[1]); this.width=parseFloat(s.geometricBounds[2]-s.geometricBounds[0]); this.height=parseFloat(s.geometricBounds[1]-s.geometricBounds[3]); this.col=parseFloat(col); this.row=parseFloat(row); this.space=parseFloat(space); this.s=s; this.maxWidth=parseFloat((this.jiaoxian+this.chuxue)*2+(this.width+this.space)*col-this.space); this.maxHeight=parseFloat((this.jiaoxian+this.chuxue)*2+(this.height+this.space)*row-this.space); this.toString=function () { var thedate = new Date() 时间 = thedate.getFullYear() + '-' + thedate.getMonth() + '-' + thedate.getDate() //2016-3-5 15:01:08 var 文件名=app.activeDocument.name; var 你要加什么="你要加什么"; return 时间+"|"+文件名+"|"+你要加什么; } } //添加所有的脚线 function addLines(imp){ //添加 var doc = app.activeDocument; var list=new Array(); //角落 list[list.length]=new bounds(imp.jiaoxian,imp.jiaoxian,0,imp.jiaoxian);//1 list[list.length]=new bounds(imp.jiaoxian,imp.jiaoxian+imp.chuxue,0,imp.jiaoxian+imp.chuxue);//2 list[list.length]=new bounds(imp.jiaoxian,imp.maxHeight-imp.jiaoxian,0,imp.maxHeight-imp.jiaoxian);//3 list[list.length]=new bounds(imp.jiaoxian,imp.maxHeight-imp.jiaoxian-imp.chuxue,0,imp.maxHeight-imp.jiaoxian-imp.chuxue);//4 list[list.length]=new bounds(imp.maxWidth-imp.jiaoxian,imp.jiaoxian,imp.maxWidth,imp.jiaoxian);//1 list[list.length]=new bounds(imp.maxWidth-imp.jiaoxian,imp.jiaoxian+imp.chuxue,imp.maxWidth,imp.jiaoxian+imp.chuxue);//2 list[list.length]=new bounds(imp.maxWidth-imp.jiaoxian,imp.maxHeight-imp.jiaoxian,imp.maxWidth,imp.maxHeight-imp.jiaoxian);//3 list[list.length]=new bounds(imp.maxWidth-imp.jiaoxian,imp.maxHeight-imp.jiaoxian-imp.chuxue,imp.maxWidth,imp.maxHeight-imp.jiaoxian-imp.chuxue);//4 list[list.length]=new bounds(imp.jiaoxian,0,imp.jiaoxian,imp.jiaoxian);//1 list[list.length]=new bounds(imp.jiaoxian+imp.chuxue,0,imp.jiaoxian+imp.chuxue,imp.jiaoxian);//2 list[list.length]=new bounds(imp.maxWidth-imp.jiaoxian,0,imp.maxWidth-imp.jiaoxian,imp.jiaoxian);//3 list[list.length]=new bounds(imp.maxWidth-imp.jiaoxian-imp.chuxue,0,imp.maxWidth-imp.jiaoxian-imp.chuxue,imp.jiaoxian);//4 list[list.length]=new bounds(imp.jiaoxian,imp.maxHeight-0,imp.jiaoxian,imp.maxHeight-imp.jiaoxian);//1 list[list.length]=new bounds(imp.jiaoxian+imp.chuxue,imp.maxHeight-0,imp.jiaoxian+imp.chuxue,imp.maxHeight-imp.jiaoxian);//2 list[list.length]=new bounds(imp.maxWidth-imp.jiaoxian,imp.maxHeight-0,imp.maxWidth-imp.jiaoxian,imp.maxHeight-imp.jiaoxian);//3 list[list.length]=new bounds(imp.maxWidth-imp.jiaoxian-imp.chuxue,imp.maxHeight-0,imp.maxWidth-imp.jiaoxian-imp.chuxue,imp.maxHeight-imp.jiaoxian);//4 //边缘 for(var i=1;i<imp.col;i++){ list[list.length]=new bounds(imp.jiaoxian+imp.chuxue+(i)*(imp.width+imp.space),0,imp.jiaoxian+imp.chuxue+(i)*(imp.width+imp.space),imp.jiaoxian); list[list.length]=new bounds(imp.jiaoxian+imp.chuxue+(i)*(imp.width+imp.space),imp.maxHeight,imp.jiaoxian+imp.chuxue+(i)*(imp.width+imp.space),imp.maxHeight-imp.jiaoxian); list[list.length]=new bounds(imp.maxWidth-(imp.jiaoxian+imp.chuxue+(i)*(imp.width+imp.space)),0,imp.maxWidth-(imp.jiaoxian+imp.chuxue+(i)*(imp.width+imp.space)),imp.jiaoxian); list[list.length]=new bounds(imp.maxWidth-(imp.jiaoxian+imp.chuxue+(i)*(imp.width+imp.space)),imp.maxHeight,imp.maxWidth-(imp.jiaoxian+imp.chuxue+(i)*(imp.width+imp.space)),imp.maxHeight-imp.jiaoxian); } for(var i=1;i<imp.row;i++){ list[list.length]=new bounds(0,imp.jiaoxian+imp.chuxue+i*(imp.height+imp.space),imp.jiaoxian,imp.jiaoxian+imp.chuxue+i*(imp.height+imp.space)); list[list.length]=new bounds(imp.maxWidth,imp.jiaoxian+imp.chuxue+i*(imp.height+imp.space),imp.maxWidth-imp.jiaoxian,imp.jiaoxian+imp.chuxue+i*(imp.height+imp.space)); list[list.length]=new bounds(0,imp.maxHeight-(imp.jiaoxian+imp.chuxue+i*(imp.height+imp.space)),imp.jiaoxian,imp.maxHeight-(imp.jiaoxian+imp.chuxue+i*(imp.height+imp.space))); list[list.length]=new bounds(imp.maxWidth,imp.maxHeight-(imp.jiaoxian+imp.chuxue+i*(imp.height+imp.space)),imp.maxWidth-imp.jiaoxian,imp.maxHeight-(imp.jiaoxian+imp.chuxue+i*(imp.height+imp.space))); } for(var i=0;i<list.length;i++){ addLine(parseFloat(imp.left+list[i].x),parseFloat(imp.top+list[i].y-imp.height),parseFloat(imp.left+list[i].x1),parseFloat(imp.top+list[i].y1-imp.height)); } } //坐标类 function bounds(x,y,x1,y1){ this.x=x; this.x1=x1; this.y=y; this.y1=y1; this.toString=function () { return "x:"+x+",y:"+y+"x1:"+x1+",y1:"+y1; } } //添加 线条 function addLine(x,y,w,d){ var line=infoGroup.pathItems.add(); var pt=72/25.4; var lw=0.1*pt; line.setEntirePath([[x,y],[w,d]]); line.strokeColor=getreg(); line.fillColor=NoColor; line.strokeWidth=lw; //指定标线宽度 return line; } //画板适应 选中 function addArtboard(s){ var doc = app.activeDocument; doc.artboards.add([s.geometricBounds[0],s.geometricBounds[1],s.geometricBounds[2],s.geometricBounds[3]]); } //获取套版色 function getreg(){ //这个代码奇丑无比。 不知道各位有没有 获取套版色的代码 for (i=0;i<activeDocument.spots.length;i++){ var newSpot1 = activeDocument.spots[i]; //获得套版色 var s = newSpot1.toString(); aa= s.indexOf('套'); bb= s.indexOf('Registration'); if ( bb !=-1){ var newSpot = activeDocument.spots[i]; //获得套版色 break; }else if (aa !=-1 ){ var newSpot = activeDocument.spots[i]; //获得套版色 break; } } regColor = new SpotColor(); regColor.spot = newSpot; return regColor; } |
||