LanyaAITools.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. #target illustrator
  2. #targetengine main
  3. var vs = "illustrator-" + app.version.substr(0, 2);
  4. // 实际代码建立 buildMsg(code) 函数传送代码
  5. function buildMsg(code) {
  6. try {
  7. var bt = new BridgeTalk;
  8. bt.target = vs;
  9. var msg = code;
  10. bt.body = msg;
  11. bt.send();
  12. } catch (e) { }
  13. }
  14. // 创建面板 使用 new Window("palette") ,需要 BridgeTalk, 它是 Adobe 应用程序之间进行通信的一种机制。
  15. // 它允许不同的 Adobe 应用程序在同一台计算机上进行交互和数据共享。
  16. // var bt = new BridgeTalk();
  17. // bt.target = "photoshop"; // 目标应用程序名称
  18. // bt.body = "alert('Hello from Illustrator!')"; // 要发送的消息或脚本
  19. // bt.send();
  20. icon_panel(); // main_panel();
  21. function main_panel() {
  22. var panel = new Window("palette", "蘭雅 Adobe Illustrator 工具箱© 2023.11.11");
  23. panel.alignChildren = ["left", "top"];
  24. panel.spacing = 2;
  25. panel.margins = 3;
  26. // 创建按钮组
  27. var BtGroup1 = panel.add("group");
  28. var BtGroup2 = panel.add("group");
  29. // 设置按钮组为水平布局
  30. BtGroup1.orientation = "row";
  31. BtGroup2.orientation = "row";
  32. // 设置按钮组的边缘间距
  33. BtGroup1.spacing = 2; // 调整按钮之间的间距
  34. BtGroup2.spacing = 2;
  35. // 添加按钮
  36. var button1 = BtGroup1.add("button", undefined, "标注尺寸");
  37. var button2 = BtGroup1.add("button", undefined, "批量旋转");
  38. var button3 = BtGroup1.add("button", undefined, "文件日期");
  39. var button4 = BtGroup1.add("button", undefined, "尺寸取整-微调-统一");
  40. var button5 = BtGroup2.add("button", undefined, "替换对齐-打包图片");
  41. var button6 = BtGroup2.add("button", undefined, "自动群组-调整尺寸");
  42. var button7 = BtGroup2.add("button", undefined, "尺寸复制");
  43. var button8 = BtGroup2.add("button", undefined, "▲");
  44. button8.preferredSize = [26, 26];
  45. button1.helpTip = "标注尺寸, <Alt>增强标注";
  46. button2.helpTip = "批量左转90度,<Alt>转180度, <Ctrl>任意角度";
  47. button3.helpTip = "咬口处插入文件名日期,<Alt>红色备注文字";
  48. button4.helpTip = "尺寸取整, <Alt-Ctrl-Shift>微调统一尺寸";
  49. button5.helpTip = "快速替换, <Alt>打包连接图";
  50. button6.helpTip = "自动群组, <Alt>调整尺寸";
  51. button7.helpTip = "尺寸复制, <Alt>包括轮廓";
  52. // 设置按钮大小与图片大小相同
  53. button8.preferredSize = [26, 26];
  54. // 按钮点击事件处理程序
  55. button1.onClick = function () {
  56. if (ScriptUI.environment.keyboardState.altKey) {
  57. // Alt 键被按下
  58. make_size_plus();
  59. } else {
  60. buildMsg("make_size();");
  61. }
  62. };
  63. button2.onClick = function () {
  64. if (ScriptUI.environment.keyboardState.ctrlKey) {
  65. // Ctrl 加鼠标左键,自定义数字
  66. var input = prompt("请输入角度数字:", "45");
  67. if (!isNaN(parseFloat(input)))
  68. buildMsg("shapes_rotate(" + input + ");");
  69. } else if (ScriptUI.environment.keyboardState.altKey) {
  70. buildMsg("shapes_rotate(180);");
  71. } else {
  72. buildMsg("shapes_rotate(90);");
  73. }
  74. };
  75. button3.onClick = function () {
  76. if (ScriptUI.environment.keyboardState.altKey) {
  77. buildMsg("mark_5mm();");
  78. } else {
  79. buildMsg("filename_date();");
  80. }
  81. };
  82. button4.onClick = function () {
  83. if (ScriptUI.environment.keyboardState.ctrlKey) {
  84. buildMsg("modify_size(-1, -1);");
  85. } else if (ScriptUI.environment.keyboardState.altKey) {
  86. buildMsg("modify_size(1, 1);");
  87. } else if (ScriptUI.environment.keyboardState.shiftKey) {
  88. // alert("ScriptUI.environment.keyboardState.shiftKey");
  89. var input = prompt("请输如宽和高两个数字(例如: 100 80):", "100 80");
  90. // 使用正则表达式匹配数字
  91. var regex = /(\d+)\s*(\d+)/;
  92. var match = input.match(regex);
  93. if (match) {
  94. var number1 = parseInt(match[1]);
  95. var number2 = parseInt(match[2]);
  96. buildMsg("set_size(" + number1 + ", " + number2 + ");");
  97. } else {
  98. alert("输入格式不正确!");
  99. }
  100. } else {
  101. buildMsg("size_to_integer();");
  102. }
  103. };
  104. button5.onClick = function () {
  105. if (ScriptUI.environment.keyboardState.altKey) {
  106. buildMsg("img_pack_links();");
  107. } else {
  108. buildMsg("replace_align_position();");
  109. }
  110. };
  111. button6.onClick = function () {
  112. if (ScriptUI.environment.keyboardState.altKey) {
  113. ResizeToSize();
  114. } else {
  115. auto_group();
  116. }
  117. };
  118. button7.onClick = function () {
  119. if (ScriptUI.environment.keyboardState.altKey) {
  120. buildMsg("size_by_controlBounds();");
  121. } else {
  122. buildMsg("size_by_width_height();");
  123. }
  124. };
  125. button8.onClick = function () {
  126. icon_panel();
  127. panel.close();
  128. };
  129. // 显示面板
  130. panel.show();
  131. }
  132. function icon_panel() {
  133. var panel = new Window("palette", "©蘭雅 Adobe Illustrator 工具箱");
  134. panel.alignChildren = ["left", "top"];
  135. panel.spacing = 2;
  136. panel.margins = 3;
  137. // 创建按钮组
  138. var BtGroup1 = panel.add("group");
  139. var BtGroup2 = panel.add("group");
  140. // 设置按钮组为水平布局
  141. BtGroup1.orientation = "row";
  142. BtGroup2.orientation = "row";
  143. // 设置按钮组的边缘间距
  144. BtGroup1.spacing = 2; // 调整按钮之间的间距
  145. BtGroup2.spacing = 2;
  146. // scriptFile = new File($.fileName); // 获取当前脚本文件的路径
  147. // var iconFile = new File(scriptFile.path + "/icon/icon.png"); // 拼接图标文件的完整路径
  148. var iconF1 = "c:/TSP/icon/size.png";
  149. var iconF2 = "c:/TSP/icon/icon.png";
  150. var iconF3 = "c:/TSP/icon/mark.png";
  151. var iconF4 = "c:/TSP/icon/debug.png";
  152. var iconF5 = "c:/TSP/icon/replace.png";
  153. var iconF6 = "c:/TSP/icon/gpucard.png";
  154. var iconF7 = "c:/TSP/icon/byBounds.png";
  155. var iconF8 = "c:/TSP/icon/repeat.png";
  156. // 添加图标按钮
  157. var button1 = BtGroup1.add("iconbutton", undefined, iconF1);
  158. var button2 = BtGroup1.add("iconbutton", undefined, iconF2);
  159. var button3 = BtGroup1.add("iconbutton", undefined, iconF3);
  160. var button4 = BtGroup1.add("iconbutton", undefined, iconF4);
  161. var button5 = BtGroup2.add("iconbutton", undefined, iconF5);
  162. var button6 = BtGroup2.add("iconbutton", undefined, iconF6);
  163. var button7 = BtGroup2.add("iconbutton", undefined, iconF7);
  164. var button8 = BtGroup2.add("iconbutton", undefined, iconF8);
  165. button1.helpTip = "标注尺寸, <Alt>增强标注";
  166. button2.helpTip = "批量左转90度,<Alt>转180度, <Ctrl>任意角度";
  167. button3.helpTip = "咬口处插入文件名日期,<Alt>红色备注文字";
  168. button4.helpTip = "尺寸取整, <Alt-Ctrl-Shift>微调统一尺寸";
  169. button5.helpTip = "快速替换, <Alt>打包连接图";
  170. button6.helpTip = "自动群组, <Alt>调整尺寸";
  171. button7.helpTip = "尺寸复制, <Alt>包括轮廓";
  172. // 设置按钮大小与图片大小相同
  173. button1.preferredSize = [48, 48];
  174. button2.preferredSize = [48, 48];
  175. button3.preferredSize = [48, 48];
  176. button4.preferredSize = [48, 48];
  177. button5.preferredSize = [48, 48];
  178. button6.preferredSize = [48, 48];
  179. button7.preferredSize = [48, 48];
  180. button8.preferredSize = [48, 48];
  181. // 按钮点击事件处理程序
  182. button1.onClick = function () {
  183. if (ScriptUI.environment.keyboardState.altKey) {
  184. // Alt 键被按下
  185. make_size_plus();
  186. } else {
  187. buildMsg("make_size();");
  188. }
  189. };
  190. button2.onClick = function () {
  191. if (ScriptUI.environment.keyboardState.ctrlKey) {
  192. // Ctrl 加鼠标左键,自定义数字
  193. var input = prompt("请输入角度数字:", "45");
  194. if (!isNaN(parseFloat(input)))
  195. buildMsg("shapes_rotate(" + input + ");");
  196. } else if (ScriptUI.environment.keyboardState.altKey) {
  197. buildMsg("shapes_rotate(180);");
  198. } else {
  199. buildMsg("shapes_rotate(90);");
  200. }
  201. };
  202. button3.onClick = function () {
  203. if (ScriptUI.environment.keyboardState.altKey) {
  204. buildMsg("mark_5mm();");
  205. } else {
  206. buildMsg("filename_date();");
  207. }
  208. };
  209. button4.onClick = function () {
  210. if (ScriptUI.environment.keyboardState.ctrlKey) {
  211. buildMsg("modify_size(-1, -1);");
  212. } else if (ScriptUI.environment.keyboardState.altKey) {
  213. buildMsg("modify_size(1, 1);");
  214. } else if (ScriptUI.environment.keyboardState.shiftKey) {
  215. // alert("ScriptUI.environment.keyboardState.shiftKey");
  216. var input = prompt("请输如宽和高两个数字(例如: 100 80):", "100 80");
  217. // 使用正则表达式匹配数字
  218. var regex = /(\d+)\s*(\d+)/;
  219. var match = input.match(regex);
  220. if (match) {
  221. var number1 = parseInt(match[1]);
  222. var number2 = parseInt(match[2]);
  223. buildMsg("set_size(" + number1 + ", " + number2 + ");");
  224. } else {
  225. alert("输入格式不正确!");
  226. }
  227. } else {
  228. buildMsg("size_to_integer();");
  229. }
  230. };
  231. button5.onClick = function () {
  232. if (ScriptUI.environment.keyboardState.altKey) {
  233. buildMsg("img_pack_links();");
  234. } else {
  235. buildMsg("replace_align_position();");
  236. }
  237. };
  238. button6.onClick = function () {
  239. if (ScriptUI.environment.keyboardState.altKey) {
  240. ResizeToSize();
  241. } else {
  242. auto_group();
  243. }
  244. };
  245. button7.onClick = function () {
  246. if (ScriptUI.environment.keyboardState.altKey) {
  247. buildMsg("size_by_controlBounds();");
  248. } else {
  249. buildMsg("size_by_width_height();");
  250. }
  251. };
  252. button8.onClick = function () {
  253. if (ScriptUI.environment.keyboardState.altKey) {
  254. mini_panel();
  255. panel.close();
  256. } else {
  257. main_panel();
  258. panel.close();
  259. }
  260. };
  261. // 显示面板
  262. panel.show();
  263. }
  264. function mini_panel() {
  265. var panel = new Window("palette", "©蘭");
  266. panel.spacing = 0;
  267. panel.margins = 0;
  268. var icon = "c:/TSP/icon/repeat.png";
  269. var button_mini = panel.add("iconbutton", undefined, icon);
  270. button_mini.preferredSize = [40, 40];
  271. button_mini.onClick = function () {
  272. icon_panel();
  273. panel.close();
  274. };
  275. panel.show();
  276. }
  277. //==================================================================================//
  278. // 蘭雅 Adobe Illustrator 工具箱© 2023.11.11 各个按钮功能模块
  279. //==================================================================================//
  280. var mm = 25.4 / 72; // pt 和 mm 转换系数
  281. // 格式化尺寸为 mm 取整数
  282. function formatSize(size) {
  283. return Math.round(size * mm).toFixed(0);
  284. }
  285. // 标注尺寸
  286. function make_size() {
  287. // 定义当前激活文档
  288. var docRef = activeDocument;
  289. var mm = 25.4 / 72; // pt 和 mm 转换系数
  290. var myFont = textFonts.getByName("MicrosoftYaHei");
  291. var myFontSize = 24;
  292. var x, y;
  293. // 格式化尺寸为 mm 取整数
  294. function formatSize(size) {
  295. return Math.round(size * mm).toFixed(0);
  296. }
  297. // 设置填充颜色为CMYK红色 (0, 100, 100, 0)
  298. var cmykRed = new CMYKColor();
  299. cmykRed.cyan = 0;
  300. cmykRed.magenta = 100;
  301. cmykRed.yellow = 100;
  302. cmykRed.black = 0;
  303. function writeText(text) {
  304. var textRef = docRef.textFrames.add(); // 建立文本
  305. textRef.contents = text;
  306. textRef.textRange.characterAttributes.size = myFontSize; // 设置字体尺寸
  307. textRef.textRange.characterAttributes.textFont = myFont; // 设置字体名称
  308. textRef.textRange.characterAttributes.fillColor = cmykRed; // 设置颜色
  309. textRef.top = y + 15 / mm;
  310. textRef.left = x + 10 / mm;
  311. }
  312. // 遍历选择的物件标注尺寸
  313. if (docRef.selection.length > 0) {
  314. var mySelection = docRef.selection;
  315. for (var i = 0; i < mySelection.length; i++) {
  316. var s = mySelection[i]
  317. x = s.left; y = s.top
  318. var str = formatSize(s.width) + "x" + formatSize(s.height) + "mm";
  319. writeText(str)
  320. }
  321. }
  322. }
  323. // 文件名日期
  324. function filename_date() {
  325. // 获取当前时间
  326. function getdate() {
  327. var d = new Date(), month = '' + (d.getMonth() + 1),
  328. day = '' + d.getDate(), year = d.getFullYear();
  329. if (month.length < 2) month = '0' + month;
  330. if (day.length < 2) day = '0' + day;
  331. return [year, month, day].join('-');
  332. }
  333. // 获取 AI文档名称
  334. var docRef = activeDocument;
  335. var str = docRef.name;
  336. str = str + " " + getdate();
  337. var base = new Array();
  338. base = docRef.rulerOrigin; // 画板标尺原点,相对于画板的左上角
  339. // alert("画板标尺原点mm x:" + base[0] * mm +" y:" + base[1] * mm + "\n画板大小mm 宽:" + docRef.width * mm +" 高:" + docRef.height * mm);
  340. var pw = 0;
  341. var ph = 0;
  342. var x = base[0]; // 画板左下角 x 坐标
  343. var y = - base[1]; // 画板左下角 y 坐标
  344. var myFont = textFonts.getByName("MicrosoftYaHei");
  345. var myFontSize = 8;
  346. pw = docRef.width; // 文档宽
  347. ph = docRef.height; // 文档高
  348. x = pw / 2 - x; // 转换x坐标: 画板中下x
  349. function filenameDate() {
  350. var textRef = docRef.textFrames.add(); // 建立文本
  351. textRef.contents = str; // 填充文本字符串: AI文档名称 + 时间
  352. textRef.textRange.characterAttributes.size = myFontSize; // 设置字体尺寸
  353. textRef.textRange.characterAttributes.textFont = myFont; // 设置字体名称
  354. textRef.textRange.characterAttributes.fillColor = docRef.swatches[1].color; // 设置拼版色
  355. textRef.top = y + 7.4; // 画板底向上偏移
  356. textRef.left = x - textRef.width - 10; // 画板x中,偏移文本宽和间隔宽
  357. textRef.selected = true;
  358. }
  359. filenameDate();
  360. }
  361. // 借咬口5mm
  362. function mark_5mm() {
  363. // 获取 AI文档名称
  364. var docRef = activeDocument;
  365. var str = docRef.name;
  366. str = "借咬口5mm"
  367. var base = new Array();
  368. base = docRef.rulerOrigin; // 画板标尺原点,相对于画板的左上角
  369. var pw = 0;
  370. var ph = 0;
  371. var x = base[0]; // 画板左下角 x 坐标
  372. var y = - base[1]; // 画板左下角 y 坐标
  373. var myFont = textFonts.getByName("MicrosoftYaHei");
  374. var myFontSize = 64;
  375. pw = docRef.width; // 文档宽
  376. ph = docRef.height; // 文档高
  377. x = pw / 2 - x; // 转换x坐标: 画板中下x
  378. // 设置填充颜色为CMYK红色 (0, 100, 100, 0)
  379. var cmykRed = new CMYKColor();
  380. cmykRed.cyan = 0;
  381. cmykRed.magenta = 100;
  382. cmykRed.yellow = 100;
  383. cmykRed.black = 0;
  384. function writeText() {
  385. var textRef = docRef.textFrames.add(); // 建立文本
  386. textRef.contents = str; // 填充文本字符串: AI文档名称 + 时间
  387. textRef.textRange.characterAttributes.size = myFontSize; // 设置字体尺寸
  388. textRef.textRange.characterAttributes.textFont = myFont; // 设置字体名称
  389. textRef.textRange.characterAttributes.fillColor = cmykRed // docRef.swatches[4].color; // 从颜色版取色简单,但是结果不确定
  390. textRef.top = y - 15; // 画板底向上偏移
  391. textRef.left = x - textRef.width / 2; // 画板x中,偏移文本宽和间隔宽
  392. textRef.selected = true;
  393. }
  394. writeText();
  395. }
  396. // 批量修改尺寸
  397. function set_size(x, y) {
  398. var sr = app.activeDocument.selection;
  399. for (var i = 0; i < sr.length; i++) {
  400. var s = sr[i];
  401. var scale_x = x / mm / s.width * 100;
  402. var scale_y = y / mm / s.height * 100;
  403. // X, Y, Positions, FillPatterns, FillGradients, StrokePattern, LineWidths
  404. s.resize(scale_x, scale_y, true, true, true, true, 100);
  405. }
  406. }
  407. // 批量增加减少尺寸
  408. function modify_size(x, y) {
  409. var sr = app.activeDocument.selection;
  410. for (var i = 0; i < sr.length; i++) {
  411. var s = sr[i];
  412. var scale_x = (formatSize(s.width) / mm + x / mm) / s.width * 100;
  413. var scale_y = (formatSize(s.height) / mm + y / mm) / s.height * 100;
  414. s.resize(scale_x, scale_y);
  415. }
  416. }
  417. // 遍历选择的物件尺寸取整
  418. function size_to_integer() {
  419. var sr = app.activeDocument.selection;
  420. for (var i = 0; i < sr.length; i++) {
  421. var s = sr[i];
  422. var scale_x = formatSize(s.width) / mm / s.width * 100;
  423. var scale_y = formatSize(s.height) / mm / s.height * 100;
  424. s.resize(scale_x, scale_y);
  425. }
  426. }
  427. // 批量物件旋转角度
  428. function shapes_rotate(angle) {
  429. var sr = app.activeDocument.selection;
  430. for (var i = 0; i < sr.length; i++)
  431. sr[i].rotate(angle);
  432. }
  433. // 物件轮廓边界
  434. function size_by_controlBounds() {
  435. var docRef = activeDocument;
  436. // 判断选择物件2个以上
  437. if (docRef.selection.length > 1) {
  438. // 定义选择物件
  439. mySelection = docRef.selection;
  440. // 最上层物件为替换源
  441. var sourceObj = docRef.selection[0];
  442. // 定义数组保存选择物件controlBounds
  443. var BoundsArray = new Array();
  444. for (var i = 0; i < mySelection.length; i++) {
  445. // PageItem.position 获得物件群组左上角坐标
  446. var sel_Bounds = mySelection[i].controlBounds;
  447. BoundsArray.push(sel_Bounds);
  448. }
  449. // PageItem.duplicate 复制对象, 需要一个相对对象定位
  450. var newGroup = sourceObj.parent.groupItems.add();
  451. for (var i = 1; i < BoundsArray.length; i++) {
  452. var width = BoundsArray[i][2] - BoundsArray[i][0];
  453. var height = BoundsArray[i][1] - BoundsArray[i][3];
  454. sourceObj.width = width;
  455. sourceObj.height = height;
  456. // 移动源文件到目的物件左上角对齐
  457. var sel_xy = new Array(BoundsArray[i][0], BoundsArray[i][1]);
  458. sourceObj.position = sel_xy;
  459. sourceObj.duplicate(newGroup, ElementPlacement.PLACEATEND);
  460. }
  461. sourceObj.remove();
  462. }
  463. }
  464. // 物件尺寸大小
  465. function size_by_width_height() {
  466. var doc = activeDocument;
  467. // 判断选择物件2个以上
  468. if (doc.selection.length > 1) {
  469. // 定义选择物件
  470. src = doc.selection;
  471. var taget = doc.selection[0];
  472. // PageItem.position 获得物件群组左上角坐标
  473. // PageItem.duplicate 复制对象, 需要一个相对对象定位
  474. // 修改taget大小, 移动到src物件左上角对齐, 复制副本
  475. var newGroup = taget.parent.groupItems.add();
  476. for (var i = 1; i < src.length; i++) {
  477. var sel_xy = src[i].position;
  478. taget.width = src[i].width;
  479. taget.height = src[i].height;
  480. taget.position = sel_xy;
  481. taget.duplicate(newGroup, ElementPlacement.PLACEATEND);
  482. }
  483. taget.remove();
  484. }
  485. }
  486. // 拼版左上对齐
  487. function replace_align_position() {
  488. var docRef = activeDocument;
  489. // 判断选择物件2个以上
  490. if (docRef.selection.length > 1) {
  491. // 定义选择物件
  492. mySelection = docRef.selection;
  493. // 最上层物件为替换源
  494. var sourceObj = docRef.selection[0];
  495. // 定义数组用来保存选择物件的左上角坐标
  496. var alterObjectArray = new Array();
  497. for (var i = 0; i < mySelection.length; i++) {
  498. // PageItem.position 获得物件群组左上角坐标
  499. var sel_xy = mySelection[i].position
  500. alterObjectArray.push(sel_xy);
  501. }
  502. // 删除用来定位的下层物件
  503. for (var i = 1; i < mySelection.length; i++) {
  504. mySelection[i].remove();
  505. }
  506. // PageItem.duplicate 复制对象, 需要一个相对对象定位
  507. var newGroup = sourceObj.parent.groupItems.add();
  508. for (var i = 1; i < alterObjectArray.length; i++) {
  509. sourceObj.position = alterObjectArray[i]; // 设置替换物的左上角位置,达到替换目的
  510. sourceObj.duplicate(newGroup, ElementPlacement.PLACEATEND);
  511. }
  512. sourceObj.remove();
  513. }
  514. }
  515. // 读取加载jsxbin文件,传递给AI软件
  516. function load_jsxbin(file) {
  517. var file = new File(file);
  518. if (file.open('r')) {
  519. var fileContent = file.read();
  520. file.close();
  521. var swap1Message = fileContent;
  522. buildMsg(swap1Message);
  523. } else {
  524. alert('文件打开失败: ' + file);
  525. }
  526. }
  527. //========== 以下插件引用使用互联网各位大大的插件 =================//
  528. // 标注尺寸增强版 V2.1
  529. function make_size_plus() {
  530. load_jsxbin("c:/TSP/icon/makesize.dat");
  531. }
  532. // 自动群组
  533. function auto_group() {
  534. load_jsxbin("c:/TSP/icon/autogroup.dat");
  535. }
  536. // 调整尺寸
  537. function ResizeToSize() {
  538. load_jsxbin("c:/TSP/icon/resize.dat");
  539. }
  540. // 打包链接图片
  541. function img_pack_links() {
  542. load_jsxbin("c:/TSP/icon/packlinks.dat");
  543. }