AI手提袋脚本
可以配合 ai_scriptmix-master 插件使用方便复制已下内容到记事本打开就行另存jsx格式
menu();
function menu() {
var res = "dialog {text: '包袋线', margins: , spacing: 8, \n\tPositive: Group {\n\t\tsText: StaticText {text: '正面长:', },\n\t\teText: EditText {preferredSize: , text: 300, active:1},\n\t\t},\n\tSide: Group {\n\t\tsText: StaticText {text: '侧面宽:', },\n\t\teText: EditText {preferredSize: , text: '80', },\n\t\t},\n\tBag: Group {\n\t\tsText: StaticText {text: '包袋高:', },\n\t\teText: EditText {preferredSize: , text: '400', },\n\t\t},\n\tSticky: Group {\n\t\tsText: StaticText {text: '粘口宽:', },\n\t\teText: EditText {preferredSize: , text: '20', },\n\t\t},\n\tFlap: Group {\n\t\tsText: StaticText {text: '勒口高:', },\n\t\teText: EditText {preferredSize: , text: '50', },\n\t\t},\n\tBottom: Group {\n\t\tsText: StaticText {text: '下底高:', },\n\t\teText: EditText {preferredSize: , text: '65', },\n\t\t},\n Bleed: Group {\n\t\tsText: StaticText {text: '出血宽:', },\n\t\teText: EditText {preferredSize: , text: '3', },\n\t\t},\n Eye: Group {\n\t\tsText: StaticText {text: '扣眼距:', },\n\t\teText: EditText {preferredSize: , text: '110', },\n\t\t},\n\tUnit: Group {\n\t\tsText: StaticText {text: '单位:', },\n\t\tddL: DropDownList {preferredSize: , properties:{items:['Pt','派卡','英寸','毫米','厘米','Ha','像素']}, },\n\t\t},\n eText: EditText {preferredSize: , properties:{multiline:true} },\n\tcom: Group {\n\t\tBtn: Button {preferredSize: , text: '确定'},\n\t\tBtn1: Button {preferredSize: , text: '取消', properties:{name:'cancel'},},\n\t\t},\n\t}";
bags = new Window(res);
bags.Unit.ddL.selection = bags.Unit.ddL.items;
var conv = 2.83464566929134;
bags.eText.text = "大2开手提袋:330mm(长) 90mm(侧面) 450mm(高)\n正2开手提袋:280mm(长) 80mm(侧面) 420mm(高)\n大3开手提袋:250mm(长) 80mm(侧面) 350mm(高)\n正3开手提袋:240mm(长) 80mm(侧面) 290mm(高)\n......";
var b = {
positive: Number(bags.Positive.eText.text) * conv,
side: Number(bags.Side.eText.text) * conv,
bag_h: Number(bags.Bag.eText.text) * conv,
sticky: Number(bags.Sticky.eText.text) * conv,
flap: Number(bags.Flap.eText.text) * conv,
bottom: Number(bags.Bottom.eText.text) * conv,
bleed: Number(bags.Bleed.eText.text) * conv,
eye: Number(bags.Eye.eText.text) * conv,
all_w: function() {
return ((this.positive + this.side) * 2) + this.sticky;
},
all_h: function() {
return this.flap + this.bag_h + this.bottom;
}
};
bags.Unit.ddL.onChange = function() {
conv = unitConv(bags.Unit.ddL.selection);
bags.Positive.eText.text = b.positive / conv;
bags.Side.eText.text = b.side / conv;
bags.Bag.eText.text = b.bag_h / conv;
bags.Sticky.eText.text = b.sticky / conv;
bags.Flap.eText.text = b.flap / conv;
bags.Bottom.eText.text = b.bottom / conv;
bags.Bleed.eText.text = b.bleed / conv;
bags.Eye.eText.text = b.eye / conv;
};
bags.Positive.eText.onChange = function() {
b.positive = Number(this.text) * conv;
};
bags.Side.eText.onChange = function() {
b.side = Number(this.text) * conv;
};
bags.Side.eText.onChanging = function() {
bags.Bottom.eText.text = Number(this.text) - (42.5196850393701 / conv);
};
bags.Bag.eText.onChange = function() {
b.bag_h = Number(this.text) * conv;
};
bags.Sticky.eText.onChange = function() {
b.sticky = Number(this.text) * conv;
};
bags.Flap.eText.onChange = function() {
b.flap = Number(this.text) * conv;
};
bags.Bottom.eText.onChange = function() {
b.bottom = Number(this.text) * conv;
};
bags.Bleed.eText.onChange = function() {
b.bleed = Number(this.text) * conv;
};
bags.Eye.eText.onChange = function() {
b.eye = Number(this.text) * conv;
};
bags.com.Btn.onClick = function() {
Bags(b);
bags.close();
};
bags.show();
}
function Bags(b) {
var doc = app.activeDocument;
W = b.all_w();
H = b.all_h();
newBlack = new GrayColor();
newBlack.gray = 100;
creat_layer();
function creat_layer() {
var layercheck = 0;
for (var u = doc.layers.length - 1; u >= 0; u--) {
var targetLayer = doc.layers;
var layerName = new String(targetLayer.name);
if (layerName.indexOf("包袋线") == 0) {
speclayer = doc.layers;
doc.layers.visible = true;
layercheck = 1;
}
}
if (layercheck == 0) {
speclayer = doc.layers.add();
speclayer.name = "包袋线";
}
}
speclayer.visible = true;
speclayerlocked = false;
var objGroup = speclayer.groupItems.add();
var rect_GP = objGroup.groupItems.add();
var line_GP = objGroup.groupItems.add();
if (app.version.slice(0, 2) >= 14) {
var padBox = doc.pathItems.rectangle(0, 0, W, H, false);
padBox.stroked = false;
doc.artboards.artboardRect = padBox.visibleBounds;
padBox.remove();
}
rectangle(rect_GP, b.bleed, -b.bleed, W + (2 * b.bleed), H + (2 * b.bleed));
function recgroup(bp, bh) {
rectangle(rect_GP, bp, 0, b.sticky, bh);
rectangle(rect_GP, bp, b.sticky, b.positive, bh);
rectangle(rect_GP, bp, b.sticky + b.positive, b.side, bh);
rectangle(rect_GP, bp, b.sticky + b.positive + b.side, b.positive, bh);
rectangle(rect_GP, bp, b.sticky + b.side + (b.positive * 2), b.side, bh);
}
recgroup(0, b.flap);
recgroup(-b.flap, b.bag_h);
recgroup(-b.flap - b.bag_h, b.bottom);
function ellipseGroup(left) {
ellipse(rect_GP, -b.flap + 77.9527559055118, left);
ellipse(rect_GP, -b.flap - 77.9527559055118, left);
}
ellipseGroup(b.sticky + ((b.positive - b.eye) / 2));
ellipseGroup(b.sticky + ((b.positive + b.eye) / 2));
ellipseGroup(b.sticky + b.positive + b.side + ((b.positive - b.eye) / 2));
ellipseGroup(b.sticky + b.positive + b.side + ((b.positive + b.eye) / 2));
line();
function line() {
var line = line_GP.pathItems.add();
setPathStyle(line, );
line.setEntirePath([
[(b.sticky + b.positive) - b.bottom, -H],
,
]);
line.duplicate().setEntirePath([
,
]);
line.duplicate().setEntirePath([
,
]);
line.duplicate().setEntirePath([
[(b.sticky + (b.positive * 2) + b.side) - b.bottom, -H],
,
]);
line.duplicate().setEntirePath([
,
]);
line.duplicate().setEntirePath([
,
]);
}
}
function rectangle(parent, y, x, w, h) {
var rect = parent.pathItems.rectangle(y, x, w, h);
setPathStyle(rect, []);
}
function ellipse(parent, top, left) {
var elli = parent.pathItems.ellipse(top, left, 14.1732283464567, 14.1732283464567, 0, 1);
setPathStyle(elli, []);
}
function setPathStyle(path, Dash) {
path.filled = false;
path.stroked = true;
path.strokeColor = newBlack;
path.strokeWidth = 0.25;
path.strokeOverprint = true;
path.strokeDashes = Dash;
}
function unitConv(UN) {
switch (UN) {
case bags.Unit.ddL.items:
conv = 1;
break;
case bags.Unit.ddL.items:
conv = 12;
break;
case bags.Unit.ddL.items:
conv = 72;
break;
case bags.Unit.ddL.items:
conv = 2.83464566929134;
break;
case bags.Unit.ddL.items:
conv = 28.3464566929134;
break;
case bags.Unit.ddL.items:
conv = 0.709;
break;
case bags.Unit.ddL.items:
conv = 1;
break;
default:
}
return conv;
}
直接复制到TXT文件就可以用了是吧,有变量噻
页:
[1]