QQ登录

只需一步,快速开始

123
返回列表 发新帖
楼主: 冰晶
收起左侧

求一个AI自动加尺寸的脚本源码

[复制链接]

尚未签到

发表于 2017-1-2 19:52:36 | 显示全部楼层
为什么要在AI标尺寸,CAD标不行吗
回复 送花

使用道具 举报

累计签到:18 天
连续签到:1 天
发表于 2017-1-9 13:42:12 | 显示全部楼层
ai 有cad标注工具的 CS5的
回复 送花

使用道具 举报

累计签到:28 天
连续签到:1 天
发表于 2017-1-22 21:09:17 | 显示全部楼层
doc = app.activeDocument; //在当前文件进行操作

theSelect = doc.selection; //对已选择的物体进行标注

sizelayer=doc.layers.add(); //新建图层
sizelayer.name = 'MZY尺寸标注';
//设置图层名称

for (i=0;i<theSelect.length;i++){ //批处理所有对象

x=theSelect[i].left;

y=theSelect[i].top;

w=theSelect[i].width;

h=theSelect[i].height;

s=40;//标尺距离物体边沿宽度
asize=20;//箭头大小
if(h<50 || w<50){asize=10;}//简单的自适应,太小的物体用小箭头
tsize=40; //标尺字体大小
redColor = new CMYKColor();//标尺用红色
redColor.black = 00;
redColor.cyan = 0;
redColor.magenta =100;
redColor.yellow = 100;
var g1 = doc.groupItems.add();//将标尺群组
var line1=g1.pathItems.add(); //画高度标尺
line1.setEntirePath( new Array(
new Array(x-s, y),
new Array(x-s, y-h),
)
) ;
line1.strokeColor= redColor;
var line1=g1.pathItems.add();
line1.setEntirePath( new Array(
new Array(x-s-s/2, y),
new Array(x-s/2, y),
)
) ;
line1.strokeColor= redColor;
var line1=g1.pathItems.add();
line1.setEntirePath( new Array(
new Array(x-s-s/2, y-h),
new Array(x-s/2, y-h),
)
) ;
line1.strokeColor= redColor;
//画箭头
var ar1=g1.pathItems.add();
ar1.setEntirePath( new Array(
new Array(x-s, y),
new Array(x-s-asize/2,y-asize),
new Array(x-s+asize/2,y-asize),
)
) ;
ar1.strokeColor= NoColor;
ar1.fillColor= redColor;
ar1.closed=true;
var ar1=g1.pathItems.add();
ar1.setEntirePath( new Array(
new Array(x-s, y-h),
new Array(x-s-asize/2,y-h+asize),
new Array(x-s+asize/2,y-h+asize),
)
) ;
ar1.strokeColor= NoColor;
ar1.fillColor= redColor;
ar1.closed=true;
var t1 = g1.textFrames.add();
t1.contents = Math.round(h*0.35277778)+" mm"; //小数位四舍五入取整数
t1.textRange.characterAttributes.size=tsize;
t1.textRange.characterAttributes.fillColor= redColor;
t1.left = x-s-t1.width/1.2;

t1.top = y-h/2+t1.height/2;

t1.rotate(90); //文字旋转90度



var line2=g1.pathItems.add();
var line2=g1.pathItems.add(); //画长度标尺
line2.setEntirePath( new Array(
new Array(x, y-h-s),
new Array(x+w, y-h-s),
)
) ;
line2.strokeColor= redColor;
var line2=g1.pathItems.add();
line2.setEntirePath( new Array(
new Array(x, y-h-s-s/2),
new Array(x, y-h-s/2),
)
) ;
line2.strokeColor= redColor;
var line2=g1.pathItems.add();
line2.setEntirePath( new Array(
new Array(x+w, y-h-s-s/2),
new Array(x+w, y-h-s/2),
)
) ;
line2.strokeColor= redColor;
//画箭头
var ar1=g1.pathItems.add();
ar1.setEntirePath( new Array(
new Array(x,y-h-s),
new Array(x+asize,y-h-s-asize/2),
new Array(x+asize,y-h-s+asize/2),
)
) ;
ar1.strokeColor= NoColor;
ar1.fillColor= redColor;
ar1.closed=true;
var ar1=g1.pathItems.add();
ar1.setEntirePath( new Array(
new Array(x+w,y-h-s),
new Array(x+w-asize,y-h-s-asize/2),
new Array(x+w-asize,y-h-s+asize/2),
)
) ;
ar1.strokeColor= NoColor;
ar1.fillColor= redColor;
ar1.closed=true;

var t2 = g1.textFrames.add();
t2.contents = Math.round(w*0.35277778)+" mm"; //小数位四舍五入取整数
t2.textRange.characterAttributes.size=tsize;
t2.textRange.characterAttributes.fillColor= redColor;
t2.left = x+w/2-t2.width/2;
t2.top = y-h-s-s;
}
回复 送花

使用道具 举报

累计签到:27 天
连续签到:0 天
发表于 2017-4-7 13:36:41 | 显示全部楼层
我之前好像见过这个AI插件
回复 送花

使用道具 举报

累计签到:14 天
连续签到:1 天
发表于 2017-4-25 08:07:59 | 显示全部楼层
试试这个AI自动加尺寸的脚本,
回复 送花

使用道具 举报

累计签到:351 天
连续签到:0 天
 楼主| 发表于 2017-4-26 11:51:07 | 显示全部楼层
有没有不要那些箭头 只要简易一点就行 就标下面的
回复 送花

使用道具 举报

累计签到:225 天
连续签到:0 天
发表于 2017-5-6 12:37:37 | 显示全部楼层
cad插件好像有这个功能
回复 送花

使用道具 举报

累计签到:161 天
连续签到:2 天
发表于 2017-8-22 20:13:24 | 显示全部楼层
这个脚本对于安装广告的还是很有用的
回复 送花

使用道具 举报

您需要登录后才可以回帖 登录 | 注册帐号

本版积分规则

关闭

注意注意注意:必看上一条 /1 下一条

华印网 - 华印社区
Share More 周一至周日:09:00 - 21:00
华印网旗下的设计印刷制作类专业技术站点
请勿发布违反国家法律法规的内容,会员观点不代表本站立场
企鹅群号:119572101

华印网汇集印前印后技术、PDF拼版、防伪包装、数码印刷、合版印刷、图文设计、平面设计、数码印刷及CTP等最新印刷技术,提供软件汉化、插件汉化、cdr插件、ai插件、ps插件、pdf插件、印刷流程、ctp输出、印刷软件、印能捷、esko、CorelDRAW、InDesign、Illustrator、CTP、CDR以及PDF软件下载的综合性印刷论坛社区!

Powered by Discuz! X3.4 © 2001-2021,Tencent Cloud.

站点地图|小黑屋|手机版|Archiver|华印 ( 粤ICP备19020152号-1 )

GMT+8, 2024-4-26 19:15 , Processed in 0.036418 second(s), 31 queries , Gzip On, Yac On.

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