论坛帮助 |
社区圈子 |
日历事件 |
2024-08-05, 22:01 | 只看该作者 #61 | |||
|
||||
正式会员
等级: 七袋长老
|
常用----------------- 标注横尺寸 标注纵尺寸 极速标注V4.6 超速标注V1.2 标注尺寸增强 连续标注尺寸 打开多页PDF 置入PDF多页面 导PDF拆分画板 选择导出-PSD 多文件批量导jpg 创建参考线 统一图片分辨率 选择范围另存AI 嵌入图转链接图 批量替换链接图 链接图建文档名 画板----------------- 按对象创建画板 排序/加框/分割 画板划分Pro 画板适合对象 对象居中画板 修改画板 多图层转多画板 画板对象裁切 移除画板 画板批量命名 调整画板和对象 旋转画板和对象 统一画板尺寸 画板增减尺寸 群组所有页面 对象适配界面 页面适配对象 选择对象对齐画板 当前画板加矩形 全部画板加矩形 统—画板尺寸 垂直两分 水平两分 文本----------------- 文本段落转换 文本段落分行 文本段落合并 大小写转换 单行拆单字 文字转曲 正则文本属性 正则查找替换 高级查找替换 印前----------------- 查看文件版本 检查文本溢出 印前检查 标注四色值 统一四色黑 全部颜色转黑 专色转为印刷色 文档优化 裁切标记 刀线属性设置 刀线生成出血线 标记线生成器 标记生成特制A 流水号生成器 色号生成器 极速色标V1.1 手绘刀版转线条 印前角线V26.3 印前角线X8.3 轮转角线V3.5 轮转机印刷标记 自订图层名/专色 删除文档专色 查找白色叠印 移除叠印属性 移除非纯黑叠印 一键拼版 自动拼版 群组拼版 极速拼版V2.0 阵列复制 阵列复制V1.2 缩放中心阵列 路径----------------- 测量路径周长 计算周长面积 黄金比例绘图 等分路径 锚点分割路径 建立等分圆 点到点连线 剪切路径 反向路径 创建内切圆 创建外接圆 创建公切线 选择节点类型 自动画角平分线 闭合开放路径 多段路径连接 修改圆滑路径 锚点选择 分割曲线锚点 反转路径方向 删除选择的描点 锚点手柄变形 所有锚点变圆角 快速锐化角 对象----------------- 超级批量替换对象 批量替换保留对象 批量替换删除对象 对象A替换B 对象替换V2.0 对象排列 校正对象水平 对象复制到锚点 对象按中心互换 按对象拆分图层 对象移到新图层 沿路径复制对象 选中对象去重线 解锁全部对象 统计所选对象 对象添加外圆 对象随机排版 对象吸附路径锚点 包装----------------- 包装盒型1.0 包装盒型2.0 天地盖盒子 绘制手提袋 手提袋Pro 极速手提袋V4.6 绘制纸箱 书籍封面版型 条形码制作 二维码生成器 批量条码EAN13 设计----------------- 选择相同增强 图片恢复100% 批量导图改尺寸 统一尺寸 统一线宽 调整对象大小 调整尺寸 插入页码等 随机缩放旋转 随机填色 随机虚线 随机应用 随机透明度 智能填充 圆角工具V2.3 创建无缝拼接图 快速创建对开页 删除所有蒙版 解散全部群组 自动群组 智能群组 命名查找器 CMYK查找潘通色 CMYK图表生成器 —键随机颜色 批量加边框 选择同类型 内角线生成器 选择字号相同字 修改字串及大小 刀版上色/线条 统—角度方向 批量镜像和旋转 融合圆球 融合圆球(弧) 加高光/阴影色板 描边快速虚线 角加圆点形状 圆形随机填充 拼图分割 重新缩放 链接文件打包 画板导出PDF/图片 选择导出PDF/JPG 新版JPG/PDF导出 其他----------------- 自动创建日历 创建时钟表盘 创建近似圆 AI变量巫术师 AI变量导入 使用说明 |
|||
回复时引用此帖 |
2024-08-06, 10:29 | 只看该作者 #66 | ||
|
|||
正式会员
等级: 二袋长老
|
var thePlacedItems = doc.placedItems; var theRasterItems = doc.rasterItems; var linksfolder = "links"; var imagesfolder = "/" + linksfolder + "/"; var docName = "/" + doc.name; var preselectedFolder = "/d/Паша/"; var strSaveDialog = "Select a folder to package files"; var ver = 12; var saveOptions = new IllustratorSaveOptions(); switch (ver) { case 3: saveOptions.compatibility = Compatibility.ILLUSTRATOR3; break; case 8: saveOptions.compatibility = Compatibility.ILLUSTRATOR8; break; case 9: saveOptions.compatibility = Compatibility.ILLUSTRATOR9; break; case 10: saveOptions.compatibility = Compatibility.ILLUSTRATOR10; break; case 11: saveOptions.compatibility = Compatibility.ILLUSTRATOR11; break; case 12: saveOptions.compatibility = Compatibility.ILLUSTRATOR12; break; } saveOptions.overprint = PDFOverprint.PRESERVEPDFOVERPRINT; if (ver <= 9) { saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE; } if (ver >= 7) { saveOptions.embedLinkedFiles = false; } if (ver >= 9) { saveOptions.fontSubsetThreshold = 100; saveOptions.embedICCProfile = false; } if (ver >= 10) { saveOptions.compressed = true; saveOptions.pdfCompatible = false; } if (documents.length > 0) { if (doc.saved == false) { alert('文件必须保存后才能打包!', 'Package', true); } else { var destFolder = Folder.selectDialog(strSaveDialog, preselectedFolder); if (destFolder != null) { var folder = new Folder(destFolder); folder.create(); imagesfolder = destFolder + imagesfolder; var folder = new Folder(imagesfolder); folder.create(); ConvertText(); for (var i = 0; i < thePlacedItems.length; i++) { source = thePlacedItems[i].file.fullName; newSource = new File(source); target = imagesfolder + thePlacedItems[i].file.name; if (newSource != null) { newSource.copy(target); } newTarget = new File(target); thePlacedItems[i].file = newTarget; } targetFile = destFolder + docName; var saveName = new File(targetFile); doc.saveAs(saveName, saveOptions); } } } function ConvertText() { var doc = app.activeDocument; for (var i = 0; i < doc.layers.length; i++) { var currentLayer = doc.layers[i]; currentLayer.locked = false; } while (doc.textFrames.length > 0) { doc.textFrames[0].createOutline(); } } |
||
回复时引用此帖 |
2024-08-06, 10:29 | 只看该作者 #67 | ||
|
|||
正式会员
等级: 二袋长老
|
var artboards = doc.artboards; var fontSize = 10; var textColor = new RGBColor(); textColor.red = 255; textColor.green = 0; textColor.blue = 0; var numberingLayer = doc.layers.add(); numberingLayer.name = "编号"; for (var i = 0; i < artboards.length; i++) { var artboard = artboards[i]; var left = artboard.artboardRect[0]; var top = artboard.artboardRect[1]; var width = artboard.artboardRect[2] - artboard.artboardRect[0]; var height = artboard.artboardRect[1] - artboard.artboardRect[3]; var centerX = left + width / 2; var centerY = top - height / 2; var textFrame = numberingLayer.textFrames.add(); textFrame.contents = (i + 1).toString(); textFrame.textRange.characterAttributes.size = fontSize + width / 5;; textFrame.textRange.characterAttributes.fillColor = textColor; textFrame.top = centerY + textFrame.height / 2; textFrame.left = centerX - textFrame.width / 2; } |
||
回复时引用此帖 |
2024-08-06, 10:30 | 只看该作者 #68 | ||
|
|||
正式会员
等级: 二袋长老
|
for (var i = artboards.length - 1; i >= 0; i--) { app.activeDocument.artboards.setActiveArtboardIndex(i); app.executeMenuCommand('selectallinartboard'); if (app.activeDocument.selection.length === 0) { app.activeDocument.artboards[i].remove(); } } |
||
回复时引用此帖 |
2024-08-06, 10:31 | 只看该作者 #69 | ||
|
|||
正式会员
等级: 二袋长老
|
// adobe Illustrator CSx script // breaks each dashed path into a series of lines // // USAGE: // Select paths and run this script. // // NOTE1: Illustrator's native dashes adjustment // feature is ignored because it is totally // out of control from JavaScript. // // 2018.07.20, modified to ignore locked/hidden objects in a selected group // Copyright(c) 2014 Hiroyuki Sato // https://github.com/shspage // This script is distributed under the MIT License. // See the LICENSE file for details. function main(){ // use_group: set true to gather broken paths into a group var use_group = true; var paths = []; getPathItemsInSelection(1, paths); if( paths.length < 1 ){ alert("nothing to do with this script\r" + "because there's no path in the selection"); return; } var grp = use_group ? activeDocument.activeLayer.groupItems.add() : undefined; for (var i = 0; i < paths.length; i++){ if (paths[i].strokeDashes.length > 0){ breakDashes(paths[i], grp); } } } // -------------------------------------------- function breakDashes(line, grp){ var sd = line.strokeDashes; if(sd.length == 1){ sd.push(sd[0]); } for (var i = 0; i < line.pathPoints.length; i++){ var next_i = parseIdx(line.pathPoints, i + 1); if(next_i < 0) break; // gets the anchor points on both ends var a1 = line.pathPoints[i].anchor; var a2 = line.pathPoints[next_i].anchor; // if the line is curve, it needs another method if(!arrEq(a1, line.pathPoints[i].rightDirection) || !arrEq(a2, line.pathPoints[next_i].leftDirection)){ breakDashesForCurve(line, i, next_i, sd, grp); continue; } // gets the angle in radian var t = getRad(a1, a2); var line_length = dist(a1, a2); var sd1 = adjustDashes(sd, line_length); // draws a segment as a line with no dashes // if the length of the segment is shorter // than 1st dash. if(sd1.length < 1){ var p = line.duplicate(); p.closed = false; p.strokeDashes = []; p.setEntirePath([a1, a2]); if(grp) p.move(grp, ElementPlacement.PLACEATEND); continue; } var offset = sd1[0] / 2; var total_length = 0; var is_gap = true; var finish = false; while(true){ for(var j = 0; j < sd1.length; j++){ var d = sd1[j]; if(offset > 0){ d -= offset; offset = 0; } total_length += d; if( total_length >= line_length ){ var a3 = a2; finish = true; } else { var a3 = [ Math.cos(t) * d + a1[0], Math.sin(t) * d + a1[1] ]; } is_gap = (! is_gap); if(! is_gap){ var p = line.duplicate(); p.closed = false; p.strokeDashes = []; p.setEntirePath([a1, a3]); if(grp) p.move(grp, ElementPlacement.PLACEATEND); } a1 = a3; if(finish) break; } if(finish) break; } } line.remove(); } // ---------------------------------------------- function adjustDashes(sd, line_length, grp){ var sd1; var dashes_length = 0; for (var i = 0; i < sd.length; i++){ dashes_length += sd[i]; } if(dashes_length == 0){ sd1 = []; } else if(sd[0] > 0 && line_length <= sd[0]){ sd1 = []; } else { var dashes_count = Math.floor(line_length / dashes_length + 0.6) || 1; sd1 = sd.slice(0); var ratio = line_length / (dashes_count * dashes_length); for(var j = 0; j < sd1.length; j++){ sd1[j] *= ratio; } } return sd1; } // ---------------------------------------------- // return distance between p1 [x,y], p2 [x,y] function dist(p1, p2) { return Math.sqrt( Math.pow(p1[0] - p2[0], 2) + Math.pow(p1[1] - p2[1], 2) ); } // ---------------------------------------------- // return angle of the line drawn from "p1" [x,y] to "p2" [x,y] function getRad(p1, p2) { return Math.atan2(p2[1] - p1[1], p2[0] - p1[0]); } // -------------------------------------- // if the contents of both arrays are equal, return true (lengthes must be same) function arrEq(arr1, arr2) { for(var i = 0; i < arr1.length; i++){ if (arr1[i] != arr2[i]) return false; } return true; } // ---------------------------------------------- // return the index of pathpoint. when the argument is out of bounds, // fixes it if the path is closed (ex. next of last index is 0), // or return -1 if the path is not closed. function parseIdx(p, n){ // PathPoints, number for index var len = p.length; if( p.parent.closed ){ return n >= 0 ? n % len : len - Math.abs(n % len); } else { return (n < 0 || n > len - 1) ? -1 : n; } } // ------------------------------------------------ // extracts PathItems from the selection which length of PathPoints // is greater than "n" function getPathItemsInSelection(n, paths){ if(documents.length < 1) return; var s = activeDocument.selection; if (!(s instanceof Array) || s.length < 1) return; extractPaths(s, n, paths); } // -------------------------------------- // extracts PathItems from "s" (Array of PageItems -- ex. selection), // and put them into an Array "paths". If "pp_length_limit" is specified, // this function extracts PathItems which PathPoints length is greater // than this number. function extractPaths(s, pp_length_limit, paths){ for(var i = 0; i < s.length; i++){ if(s[i].locked || s[i].hidden){ continue; } else if(s[i].typename == "PathItem"){ if(pp_length_limit && s[i].pathPoints.length <= pp_length_limit){ continue; } paths.push(s[i]); } else if(s[i].typename == "GroupItem"){ // search for PathItems in GroupItem, recursively extractPaths(s[i].pageItems, pp_length_limit, paths); } else if(s[i].typename == "CompoundPathItem"){ // searches for pathitems in CompoundPathItem, recursively // ( ### Grouped PathItems in CompoundPathItem are ignored ### ) extractPaths(s[i].pathItems, pp_length_limit , paths); } } } // ----------------------------------------------- var Point = function(){ this.x = 0; this.y = 0; } Point.prototype = { set : function(x, y){ this.x = x; this.y = y; return this; }, setr : function(xy){ // set with an array this.x = xy[0]; this.y = xy[1]; return this; }, setp : function(p){ // set with a Point this.x = p.x; this.y = p.y; return this; }, addp : function(p){ return new Point().set( this.x + p.x, this.y + p.y ); }, subp : function(p){ return new Point().set( this.x - p.x, this.y - p.y ); }, mul : function(m){ return new Point().set( this.x * m, this.y * m ); }, rotate : function(rad){ var s = Math.sin(rad); var c = Math.cos(rad); return new Point().set( this.x * c - this.y * s, this.x * s + this.y * c ); }, getAngle : function(){ return Math.atan2( this.y, this.x ); // radian }, normalize : function(){ var d = Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2)); var p = new Point(); if( d == 0 ){ p.set(0,0); } else { p.set(this.x / d, this.y / d); } return p; }, toArray : function(){ return [this.x, this.y]; } } // ----------------------------------------------- var Curve = function(path, idx1, idx2){ this.path = path; this.idx1 = idx1; this.idx2 = idx2; var pts = path.pathPoints; this.p1 = new Point().setr(pts[idx1].anchor); this.rdir = new Point().setr(pts[idx1].rightDirection); this.ldir = new Point().setr(pts[idx2].leftDirection); this.p2 = new Point().setr(pts[idx2].anchor); this.q = [this.p1, this.rdir, this.ldir, this.p2]; this.params = null; this.length = null; } Curve.prototype = { bezier : function(t){ var u = 1 - t; return new Point().set( u*u*u * this.p1.x + 3*u*t*(u* this.rdir.x + t* this.ldir.x) + t*t*t * this.p2.x, u*u*u * this.p1.y + 3*u*t*(u* this.rdir.y + t* this.ldir.y) + t*t*t * this.p2.y); }, setParams : function(){ var m = [this.p2.x - this.p1.x + 3 * (this.rdir.x - this.ldir.x), this.p1.x - 2 * this.rdir.x + this.ldir.x, this.rdir.x - this.p1.x]; var n = [this.p2.y - this.p1.y + 3 * (this.rdir.y - this.ldir.y), this.p1.y - 2 * this.rdir.y + this.ldir.y, this.rdir.y - this.p1.y]; this.params = [ m[0] * m[0] + n[0] * n[0], 4 * (m[0] * m[1] + n[0] * n[1]), 2 * ((m[0] * m[2] + n[0] * n[2]) + 2 * (m[1] * m[1] + n[1] * n[1])), 4 * (m[1] * m[2] + n[1] * n[2]), m[2] * m[2] + n[2] * n[2]]; }, clone : function(){ var c = new Curve(this.path, this.idx1, this.idx2); c.params = this.params; c.length = this.length; return c; }, getLength : function(t){ //if( !this.params ) this.setParams(); var k = this.params; var h = t / 128; var hh = h * 2; var fc = function(t, k){ return Math.sqrt(t * (t * (t * (t * k[0] + k[1]) + k[2]) + k[3]) + k[4]) || 0 }; var total = (fc(0, k) - fc(t, k)) / 2; for(var i = h; i < t; i += hh){ total += 2 * fc(i, k) + fc(i + h, k); } return total * hh; }, getLeftDirForT : function(t){ return new Point().set( t * (t * (this.p1.x - 2 * this.rdir.x + this.ldir.x) + 2 * (this.rdir.x - this.p1.x)) + this.p1.x, t * (t * (this.p1.y - 2 * this.rdir.y + this.ldir.y) + 2 * (this.rdir.y - this.p1.y)) + this.p1.y); }, getRightDirForT : function(t){ return new Point().set( t * (t * (this.rdir.x - 2 * this.ldir.x + this.p2.x) + 2 * (this.ldir.x - this.rdir.x)) + this.rdir.x, t * (t * (this.rdir.y - 2 * this.ldir.y + this.p2.y) + 2 * (this.ldir.y - this.rdir.y)) + this.rdir.y); }, resetPoints : function(p1, rdir, ldir, p2){ this.p1 = p1; this.rdir = rdir; this.ldir = ldir; this.p2 = p2; this.q = [p1, rdir, ldir, p2]; }, getContractedRdir : function(m){ return this.p1.addp(this.rdir.subp(this.p1).mul(m)); }, getContractedLdir : function(m){ return this.p2.addp(this.ldir.subp(this.p2).mul(m)); }, getPartForTAndLength : function(t, len){ var c = this.clone(); c.resetPoints(this.bezier(t), this.getRightDirForT(t), this.getContractedLdir(1 - t), this.p2); c.setParams(); c.length = c.getLength(1); var t1 = c.getTforLength(len); c.resetPoints(c.p1, c.getContractedRdir(t1), c.getLeftDirForT(t1), c.bezier(t1)); return c; }, getTforLength : function(len){ //if( !this.params ) this.setParams(); var k = this.params; //if( !this.length) this.length = this.getLength(1); if(len <= 0){ return 0; } else if(len > this.length){ return 1; } var t, d; var t0 = 0; var t1 = 1; var torelance = 0.001; for(var h = 1; h < 30; h++){ t = t0 + (t1 - t0) / 2; d = len - this.getLength(t); if(Math.abs(d) < torelance) break; else if(d < 0) t1 = t; else t0 = t; } return Math.min(1, t); } } // -------------------------------------------- function breakDashesForCurve(line, i, next_i, sd, grp){ var cv = new Curve(line, i, next_i); cv.setParams(); cv.length = cv.getLength(1); var line_length = cv.length; var sd1 = adjustDashes(sd, line_length); // draws a segment as a line with no dashes // if the length of the segment is shorter // than 1st dash. if(sd1.length < 1){ var p = line.duplicate(); p.closed = false; p.strokeDashes = []; var pp = p.pathPoints; var rdir = pp[i].rightDirection; var ldir = pp[next_i].leftDirection; p.setEntirePath([pp[i].anchor, pp[next_i].anchor]); pp = p.pathPoints; pp[0].rightDirection = rdir; pp[1].leftDirectin = ldir; if(grp) p.move(grp, ElementPlacement.PLACEATEND); return; } var offset = sd1[0] / 2; var total_length = 0; var is_gap = true; var finish = false; while(true){ for(var j = 0; j < sd1.length; j++){ var d = sd1[j]; if(offset > 0){ d -= offset; offset = 0; } if( total_length + d >= line_length ){ finish = true; } is_gap = (! is_gap); if(! is_gap){ var t = cv.getTforLength(total_length); var cv1 = cv.getPartForTAndLength(t, d); var p = line.duplicate(); p.closed = false; p.strokeDashes = []; p.setEntirePath([cv1.p1.toArray(), cv1.p2.toArray()]); p.pathPoints[0].rightDirection = cv1.rdir.toArray(); p.pathPoints[1].leftDirection = cv1.ldir.toArray(); if(grp) p.move(grp, ElementPlacement.PLACEATEND); } if(finish) break; total_length += d; } if(finish) break; } } // ---------------------------------------------- main(); |
||
回复时引用此帖 |
2024-08-06, 10:32 | 只看该作者 #70 | ||
|
|||
正式会员
等级: 二袋长老
|
var theSelect = doc.selection; var objGBCheck = true; //几何边界与可视边界 切换 //true //false var addLayerCheck = false; //是否新建图层 var addColorCheck = false; //边框是否填色 var layName = "边框图层"; //新建的图层名称 if (theSelect.length > 0) { for (i = 0; i < theSelect.length; i++) { //批处理多个选择物体 var bound = NO_CLIP_BOUNDS(theSelect[i]); var left = bound[0]; //左 var tops = bound[1]; //上 var width = bound[2] - bound[0]; //宽 var height = bound[1] - bound[3]; //高 if (addLayerCheck == true) { try { var newLayer = doc.layers[layName]; //查找图层 newLayer.locked = false; newLayer.visible = true; } catch(err) { var newLayer = doc.layers.add();//新建图层 newLayer.name = layName; } var rect = newLayer.pathItems.rectangle(tops, left, width, height); //创建边框 } else { var rect = doc.activeLayer.pathItems.rectangle(tops, left, width, height); //创建边框 } var newColor = new CMYKColor(); //创建 CMYK 颜色 newColor.cyan = 0; newColor.magenta = 0; newColor.yellow = 0; newColor.black = 100; if (addColorCheck == true) { rect.stroked = true; //描边 rect.strokeWidth = 0.25; //线粗 rect.strokeColor = newColor; //描边的颜色 } else { rect.stroked = false; //无描边 } rect.filled = false; //不填充 rect.fillColor = NoColor; //无填充色 rect.selected = true; //被选中 doc.artboards.add(bound); } } else { alert("唉吆!\n必须先选择对象文件哦!!", "错误提示"); } function NO_CLIP_BOUNDS(the_obj) { var NO_CLIP_OBJECTS_AND_MASKS = new Array(); GET_NO_CLIP_OBJECTS_AND_MASKS(the_obj); var v_left = new Array(); var g_left = new Array(); var v_top = new Array(); var g_top = new Array(); var v_right = new Array(); var g_right = new Array(); var v_bottom = new Array(); var g_bottom = new Array(); for (var i = 0; i < NO_CLIP_OBJECTS_AND_MASKS.length; i += 1) { g_left[i] = NO_CLIP_OBJECTS_AND_MASKS[i].geometricBounds[0]; v_left[i] = NO_CLIP_OBJECTS_AND_MASKS[i].visibleBounds[0]; g_top[i] = NO_CLIP_OBJECTS_AND_MASKS[i].geometricBounds[1]; v_top[i] = NO_CLIP_OBJECTS_AND_MASKS[i].visibleBounds[1]; g_right[i] = NO_CLIP_OBJECTS_AND_MASKS[i].geometricBounds[2]; v_right[i] = NO_CLIP_OBJECTS_AND_MASKS[i].visibleBounds[2]; g_bottom[i] = NO_CLIP_OBJECTS_AND_MASKS[i].geometricBounds[3]; v_bottom[i] = NO_CLIP_OBJECTS_AND_MASKS[i].visibleBounds[3]; } var GV_Bounds = objGBCheck ? "true": "false"; switch (GV_Bounds) { case "true": var g_L = MIN_IN_ARRAY(g_left); var g_T = MAX_IN_ARRAY(g_top); var g_R = MAX_IN_ARRAY(g_right); var g_B = MIN_IN_ARRAY(g_bottom); return [g_L, g_T, g_R, g_B]; break; case "false": var v_L = MIN_IN_ARRAY(v_left); var v_T = MAX_IN_ARRAY(v_top); var v_R = MAX_IN_ARRAY(v_right); var v_B = MIN_IN_ARRAY(v_bottom); return [v_L, v_T, v_R, v_B]; break; } function GET_NO_CLIP_OBJECTS_AND_MASKS(the_obj) { if (IS_CLIP(the_obj)) { NO_CLIP_OBJECTS_AND_MASKS.push(the_obj.pageItems[0]); return; } if (the_obj.constructor.name == "GroupItem") { try { var N_sub_obj = the_obj.pageItems.length; for (var i = 0; i < N_sub_obj; i += 1) { GET_NO_CLIP_OBJECTS_AND_MASKS(the_obj.pageItems[i]); } } catch(error) { } return; } NO_CLIP_OBJECTS_AND_MASKS.push(the_obj); return; } } function IS_CLIP(the_obj) { try { if (the_obj.constructor.name == "GroupItem") { if (the_obj.clipped) { return true; } } } catch(error) { } return false; } function MAX_IN_ARRAY(the_array) { var MAX = the_array[0]; for (var i = 0; i < the_array.length; i += 1) { if (the_array[i] > MAX) { MAX = the_array[i] } } return MAX; } function MIN_IN_ARRAY(the_array) { var MIN = the_array[0]; for (var i = 0; i < the_array.length; i += 1) { if (the_array[i] < MIN) { MIN = the_array[i] } } return MIN; } |
||
回复时引用此帖 |
2024-08-06, 10:32 | 只看该作者 #71 | ||
|
|||
正式会员
等级: 二袋长老
|
var selectedObjects = app.activeDocument.selection; selectedObjects.sort(function(a, b) { if (a.top !== b.top) { return b.top - a.top; } else { return a.left - b.left; } }); var number = 1; var fontSize = 10; // 设置文本颜色 var textColor = new RGBColor(); textColor.red = 255; textColor.green = 0; textColor.blue = 0; // 设置文本颜色为专色 var spot = doc.spots.add(); spot.color = textColor; spot.colorType = ColorModel.SPOT; spot.name = "RED-"; var spotColor = new SpotColor(); spotColor.spot = doc.spots.getByName("RED-"); var numberingLayer = doc.layers.add(); numberingLayer.name = "编号"; for (var i = 0; i < selectedObjects.length; i++) { var s = selectedObjects[i]; var ab = s.geometricBounds; var left = ab[0]; var top = ab[1] var width = ab[2]-ab[0]; var height = ab[1]-ab[3]; var centerX = left + width / 2; var centerY = top - height / 2; var textFrame = numberingLayer.textFrames.add(); textFrame.contents = number.toString(); textFrame.textRange.characterAttributes.size = fontSize + width / 5;; textFrame.top = centerY + textFrame.height / 2; textFrame.left = centerX - textFrame.width / 2; // 设置专色叠印 textFrame.textRange.characterAttributes.fillColor = spotColor; textFrame.textRange.overprintFill = true; textFrame.textRange.overprintStroke = true; number++; } |
||
回复时引用此帖 |
2024-08-06, 10:33 | 只看该作者 #72 | ||
|
|||
正式会员
等级: 二袋长老
|
sel = doc.selection; var layercheck = false; var mm =72/25.4 for (var i = 0; i < doc.layers.length; i += 1) { if (doc.layers[i].name == "加框图层") { mylayer = doc.layers[i]; layercheck = true; } } if (layercheck == false) { mylayer = doc.layers.add(); mylayer.name = "加框图层"; mylayer.move(doc, ElementPlacement.PLACEATBEGINNING); } // 新建或检测图层 vColor = new CMYKColor(); vColor.black = 00; vColor.cyan = 30; vColor.magenta = 100; vColor.yellow = 50; // 定义颜色 for (var i = 0; i < sel.length; i += 1) { x = sel[i].geometricBounds[0]-3*mm; y = sel[i].geometricBounds[1]+3*mm; w = sel[i].width+6*mm; h = sel[i].height+6*mm; if (sel[i].typename == "GroupItem") { if (sel[i].clipped) { x = sel[i].pageItems[0].geometricBounds[0]-3*mm; y = sel[i].pageItems[0].geometricBounds[1]+3*mm; w = sel[i].pageItems[0].width+6*mm; h = sel[i].pageItems[0].height+6*mm; } } // 画矩形,定义每条边的位置 rect = mylayer.pathItems.rectangle(y, x, w, h); rect.filled = true; //填充为真 rect.fillColor = vColor; //填充颜色为定义的vColor rect.stroked = false;//描边为假 rect.zOrder(ZOrderMethod.SENDTOBACK);//将加框矩形置于图层最底部 } mylayer.zOrder(ZOrderMethod.SENDTOBACK); //将图层置于最底层 |
||
回复时引用此帖 |
2024-08-06, 10:38 | 只看该作者 #74 | ||
|
|||
正式会员
等级: 二袋长老
|
var hidel=[] var ls=activeDocument.layers for(i=ls.length-1;i>=0;i--) { if( ls[i].visible==false) {hidel.push(ls[i])} } app.executeMenuCommand('deselectall') app.executeMenuCommand('showAll')//如果有描边 var s=app.selection if (s.length>0) { for(i=0;i<s.length;i++) { hide.push(s[i]) } } if (hide.length==0&&hidel.length==0) {alert("当前文档没有隐藏对象");} else { if (hide.length>0&&hidel.length>0){ var aa= confirm("有 "+hide.length+" 个隐藏对象"+"和 "+hidel.length+" 个隐藏图层,是否删除?") } if (hide.length>0&&hidel.length==0){ var aa= confirm("有 "+hide.length+" 个隐藏对象,是否删除?") } if (hide.length==0&&hidel.length>0){ var aa= confirm("有 "+hidel.length+" 个隐藏图层,是否删除?") } if (aa==true){ if(hide.length>0) { for(i=0;i<hide.length;i++) { hide[i].remove() } } if(hidel.length>0){ //~ alert("tt") for(ii=hidel.length-1; ii>=0; ii--) { hidel[ii].visible = true; hidel[ii]. remove() } } } else { if(hide.length>0) { for(i=0;i<hide.length;i++) { hide[i].hidden=true } } } } |
||
回复时引用此帖 |