好多资源哦

 找回密码
 立即注册
查看: 374|回复: 1

AI手提袋脚本

[复制链接]
发表于 2024-8-22 14:50:43 | 显示全部楼层 |阅读模式
可以配合 ai_scriptmix-master 插件使用方便

复制已下内容到记事本打开就行  另存jsx格式

  1. menu();

  2. function menu() {
  3.     var res = "dialog {text: '包袋线', margins: [10,5,10,5], spacing: 8, \n\tPositive: Group {\n\t\tsText: StaticText {text: '正面长:', },\n\t\teText: EditText {preferredSize: [60,20], text: 300, active:1},\n\t\t},\n\tSide: Group {\n\t\tsText: StaticText {text: '侧面宽:', },\n\t\teText: EditText {preferredSize: [60,20], text: '80', },\n\t\t},\n\tBag: Group {\n\t\tsText: StaticText {text: '包袋高:', },\n\t\teText: EditText {preferredSize: [60,20], text: '400', },\n\t\t},\n\tSticky: Group {\n\t\tsText: StaticText {text: '粘口宽:', },\n\t\teText: EditText {preferredSize: [60,20], text: '20', },\n\t\t},\n\tFlap: Group {\n\t\tsText: StaticText {text: '勒口高:', },\n\t\teText: EditText {preferredSize: [60,20], text: '50', },\n\t\t},\n\tBottom: Group {\n\t\tsText: StaticText {text: '下底高:', },\n\t\teText: EditText {preferredSize: [60,20], text: '65', },\n\t\t},\n    Bleed: Group {\n\t\tsText: StaticText {text: '出血宽:', },\n\t\teText: EditText {preferredSize: [60,20], text: '3', },\n\t\t},\n    Eye: Group {\n\t\tsText: StaticText {text: '扣眼距:', },\n\t\teText: EditText {preferredSize: [60,20], text: '110', },\n\t\t},\n\tUnit: Group {\n\t\tsText: StaticText {text: '单  位:', },\n\t\tddL: DropDownList {preferredSize: [60,20], properties:{items:['Pt','派卡','英寸','毫米','厘米','Ha','像素']}, },\n\t\t},\n    eText: EditText {preferredSize: [120,80], properties:{multiline:true} },\n\tcom: Group {\n\t\tBtn: Button {preferredSize: [55,20], text: '确定'},\n\t\tBtn1: Button {preferredSize: [55,20], text: '取消', properties:{name:'cancel'},},\n\t\t},\n\t}";
  4.     bags = new Window(res);
  5.     bags.Unit.ddL.selection = bags.Unit.ddL.items[3];
  6.     var conv = 2.83464566929134;
  7.     bags.eText.text = "大2开手提袋:330mm(长)    90mm(侧面)   450mm(高)\n正2开手提袋:280mm(长)     80mm(侧面)   420mm(高)\n大3开手提袋:250mm(长)     80mm(侧面)   350mm(高)\n正3开手提袋:240mm(长)     80mm(侧面)   290mm(高)\n......";
  8.     var b = {
  9.         positive: Number(bags.Positive.eText.text) * conv,
  10.         side: Number(bags.Side.eText.text) * conv,
  11.         bag_h: Number(bags.Bag.eText.text) * conv,
  12.         sticky: Number(bags.Sticky.eText.text) * conv,
  13.         flap: Number(bags.Flap.eText.text) * conv,
  14.         bottom: Number(bags.Bottom.eText.text) * conv,
  15.         bleed: Number(bags.Bleed.eText.text) * conv,
  16.         eye: Number(bags.Eye.eText.text) * conv,
  17.         all_w: function() {
  18.             return ((this.positive + this.side) * 2) + this.sticky;
  19.         },
  20.         all_h: function() {
  21.             return this.flap + this.bag_h + this.bottom;
  22.         }
  23.     };
  24.     bags.Unit.ddL.onChange = function() {
  25.         conv = unitConv(bags.Unit.ddL.selection);
  26.         bags.Positive.eText.text = b.positive / conv;
  27.         bags.Side.eText.text = b.side / conv;
  28.         bags.Bag.eText.text = b.bag_h / conv;
  29.         bags.Sticky.eText.text = b.sticky / conv;
  30.         bags.Flap.eText.text = b.flap / conv;
  31.         bags.Bottom.eText.text = b.bottom / conv;
  32.         bags.Bleed.eText.text = b.bleed / conv;
  33.         bags.Eye.eText.text = b.eye / conv;
  34.     };
  35.     bags.Positive.eText.onChange = function() {
  36.         b.positive = Number(this.text) * conv;
  37.     };
  38.     bags.Side.eText.onChange = function() {
  39.         b.side = Number(this.text) * conv;
  40.     };
  41.     bags.Side.eText.onChanging = function() {
  42.         bags.Bottom.eText.text = Number(this.text) - (42.5196850393701 / conv);
  43.     };
  44.     bags.Bag.eText.onChange = function() {
  45.         b.bag_h = Number(this.text) * conv;
  46.     };
  47.     bags.Sticky.eText.onChange = function() {
  48.         b.sticky = Number(this.text) * conv;
  49.     };
  50.     bags.Flap.eText.onChange = function() {
  51.         b.flap = Number(this.text) * conv;
  52.     };
  53.     bags.Bottom.eText.onChange = function() {
  54.         b.bottom = Number(this.text) * conv;
  55.     };
  56.     bags.Bleed.eText.onChange = function() {
  57.         b.bleed = Number(this.text) * conv;
  58.     };
  59.     bags.Eye.eText.onChange = function() {
  60.         b.eye = Number(this.text) * conv;
  61.     };
  62.     bags.com.Btn.onClick = function() {
  63.         Bags(b);
  64.         bags.close();
  65.     };
  66.     bags.show();
  67. }

  68. function Bags(b) {
  69.     var doc = app.activeDocument;
  70.     W = b.all_w();
  71.     H = b.all_h();
  72.     newBlack = new GrayColor();
  73.     newBlack.gray = 100;
  74.     creat_layer();

  75.     function creat_layer() {
  76.         var layercheck = 0;
  77.         for (var u = doc.layers.length - 1; u >= 0; u--) {
  78.             var targetLayer = doc.layers[u];
  79.             var layerName = new String(targetLayer.name);
  80.             if (layerName.indexOf("包袋线") == 0) {
  81.                 speclayer = doc.layers[u];
  82.                 doc.layers[0].visible = true;
  83.                 layercheck = 1;
  84.             }
  85.         }
  86.         if (layercheck == 0) {
  87.             speclayer = doc.layers.add();
  88.             speclayer.name = "包袋线";
  89.         }
  90.     }
  91.     speclayer.visible = true;
  92.     speclayerlocked = false;
  93.     var objGroup = speclayer.groupItems.add();
  94.     var rect_GP = objGroup.groupItems.add();
  95.     var line_GP = objGroup.groupItems.add();
  96.     if (app.version.slice(0, 2) >= 14) {
  97.         var padBox = doc.pathItems.rectangle(0, 0, W, H, false);
  98.         padBox.stroked = false;
  99.         doc.artboards[0].artboardRect = padBox.visibleBounds;
  100.         padBox.remove();
  101.     }
  102.     rectangle(rect_GP, b.bleed, -b.bleed, W + (2 * b.bleed), H + (2 * b.bleed));

  103.     function recgroup(bp, bh) {
  104.         rectangle(rect_GP, bp, 0, b.sticky, bh);
  105.         rectangle(rect_GP, bp, b.sticky, b.positive, bh);
  106.         rectangle(rect_GP, bp, b.sticky + b.positive, b.side, bh);
  107.         rectangle(rect_GP, bp, b.sticky + b.positive + b.side, b.positive, bh);
  108.         rectangle(rect_GP, bp, b.sticky + b.side + (b.positive * 2), b.side, bh);
  109.     }
  110.     recgroup(0, b.flap);
  111.     recgroup(-b.flap, b.bag_h);
  112.     recgroup(-b.flap - b.bag_h, b.bottom);

  113.     function ellipseGroup(left) {
  114.         ellipse(rect_GP, -b.flap + 77.9527559055118, left);
  115.         ellipse(rect_GP, -b.flap - 77.9527559055118, left);
  116.     }
  117.     ellipseGroup(b.sticky + ((b.positive - b.eye) / 2));
  118.     ellipseGroup(b.sticky + ((b.positive + b.eye) / 2));
  119.     ellipseGroup(b.sticky + b.positive + b.side + ((b.positive - b.eye) / 2));
  120.     ellipseGroup(b.sticky + b.positive + b.side + ((b.positive + b.eye) / 2));
  121.     line();

  122.     function line() {
  123.         var line = line_GP.pathItems.add();
  124.         setPathStyle(line, [5, 3]);
  125.         line.setEntirePath([
  126.             [(b.sticky + b.positive) - b.bottom, -H],
  127.             [b.sticky + b.positive + (b.side / 2), (b.bottom + (b.side / 2)) - H],
  128.             [b.sticky + b.positive + b.bottom + b.side, -H]
  129.         ]);
  130.         line.duplicate().setEntirePath([
  131.             [0, (b.bottom + b.sticky) - H],
  132.             [b.bottom + b.sticky, -H]
  133.         ]);
  134.         line.duplicate().setEntirePath([
  135.             [b.sticky + b.positive + (b.side / 2), -H],
  136.             [b.sticky + b.positive + (b.side / 2), 0]
  137.         ]);
  138.         line.duplicate().setEntirePath([
  139.             [(b.sticky + (b.positive * 2) + b.side) - b.bottom, -H],
  140.             [b.sticky + (b.positive * 2) + ((b.side * 3) / 2), (b.bottom + (b.side / 2)) - H],
  141.             [b.sticky + (b.positive * 2) + (b.side * 2), b.bottom - H]
  142.         ]);
  143.         line.duplicate().setEntirePath([
  144.             [b.sticky + (b.positive * 2) + ((b.side * 3) / 2), -H],
  145.             [b.sticky + (b.positive * 2) + ((b.side * 3) / 2), 0]
  146.         ]);
  147.         line.duplicate().setEntirePath([
  148.             [b.sticky + b.positive + (b.side / 2), (b.bottom + (b.side / 2)) - H],
  149.             [b.sticky + (b.positive * 2) + ((b.side * 3) / 2), (b.bottom + (b.side / 2)) - H]
  150.         ]);
  151.     }
  152. }

  153. function rectangle(parent, y, x, w, h) {
  154.     var rect = parent.pathItems.rectangle(y, x, w, h);
  155.     setPathStyle(rect, []);
  156. }

  157. function ellipse(parent, top, left) {
  158.     var elli = parent.pathItems.ellipse(top, left, 14.1732283464567, 14.1732283464567, 0, 1);
  159.     setPathStyle(elli, []);
  160. }

  161. function setPathStyle(path, Dash) {
  162.     path.filled = false;
  163.     path.stroked = true;
  164.     path.strokeColor = newBlack;
  165.     path.strokeWidth = 0.25;
  166.     path.strokeOverprint = true;
  167.     path.strokeDashes = Dash;
  168. }

  169. function unitConv(UN) {
  170.     switch (UN) {
  171.         case bags.Unit.ddL.items[0]:
  172.             conv = 1;
  173.             break;
  174.         case bags.Unit.ddL.items[1]:
  175.             conv = 12;
  176.             break;
  177.         case bags.Unit.ddL.items[2]:
  178.             conv = 72;
  179.             break;
  180.         case bags.Unit.ddL.items[3]:
  181.             conv = 2.83464566929134;
  182.             break;
  183.         case bags.Unit.ddL.items[4]:
  184.             conv = 28.3464566929134;
  185.             break;
  186.         case bags.Unit.ddL.items[5]:
  187.             conv = 0.709;
  188.             break;
  189.         case bags.Unit.ddL.items[6]:
  190.             conv = 1;
  191.             break;
  192.         default:

  193.     }
  194.     return conv;
  195. }
复制代码




回复

使用道具 举报

发表于 2024-8-23 17:36:58 | 显示全部楼层
直接复制到TXT文件就可以用了是吧,有变量噻
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|好多资源哦

GMT+8, 2025-1-18 15:36 , Processed in 0.123426 second(s), 14 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表