返单编号更新

2021/4/9 18:57:08

本文主要是介绍返单编号更新,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

	var doc = activeDocument;
	var pt = 72/25.4;

	
for (k=0; k<doc.artboards.length; k++) {
		
	var abBounds = doc.artboards[k].artboardRect;
	var 宽=abBounds[2]-abBounds[0];
	var 高=abBounds[1]-abBounds[3];
	
	var wh = getTextWidth();
	var x=abBounds[2]-3.34*pt;
	var y=abBounds[1]-20*pt;
	var nameF = activeDocument.name.substring(0,activeDocument.name.length-4);

	//右边
	addTextAndRect(x,y,270,2.8*pt,wh.width,nameF);
	//左边
	var x=abBounds[0]+0.7369*pt;
	var y=abBounds[1]-20*pt;
	addTextAndRect(x,y,270,2.8*pt,wh.width,nameF);
	//底部
	var x=abBounds[0]+10*pt;
	var y=abBounds[3]+wh.height-0.25*pt+0.6946*pt;
	addTextAndRect(x,y,0,wh.width,2.8*pt,nameF);

	//底部
	var x=abBounds[0]+宽/2+30*pt;
	var y=abBounds[3]+wh.height-0.25*pt+0.6946*pt;
	addTextAndRect(x,y,0,wh.width,2.8*pt,nameF);
}

function addTextAndRect(x,y,r,rw,rh,content){
	var newShape = activeDocument.pathItems.rectangle(y,x,rw,rh); 
	newShape.fillColor = getCMYKColor(0,0,0,0);
	newShape.strokeColor= NoColor;
	var text = doc.textFrames.add();
	text.contents = content;
	text.textRange.characterAttributes.size=6; //字体大小
	text.textRange.characterAttributes.textFont = textFonts.getByName("MicrosoftYaHei");
	text.textRange.characterAttributes.fillColor = getSpotColor();//填充颜色
	text.rotate(r);
	text.left=x;//距离左边的距离
	text.top =y;//距离顶边的距离
	text.createOutline();
}

function getTextWidth(){
	var text2 = doc.textFrames.add();
	text2.contents = activeDocument.name.substring(0,activeDocument.name.length-4);
	text2.textRange.characterAttributes.size=6; //字体大小
	text2.textRange.characterAttributes.textFont = textFonts.getByName("MicrosoftYaHei");
	var h = {
		width:text2.width,
		height:text2.height
	}
	text2.remove();
	return h;
	
}
function getSpotColor(){
	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]; //获得套版色
			i=activeDocument.spots.length
		}
		if (aa !=-1 ){
			var newSpot = activeDocument.spots[i]; //获得套版色
			i=activeDocument.spots.length
		}
    }
	regColor = new SpotColor();
	regColor.spot = newSpot;
	return regColor;
}
function getCMYKColor(c,m,y,k){
	var color = new CMYKColor();
	color.cyan= c;
	color.magenta = m;
	color.yellow = y;
	color.black = k;
	return color;
}

 



这篇关于返单编号更新的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程