论坛帮助 |
社区圈子 |
日历事件 |
2020-12-30, 13:30 | 只看该作者 #2 | ||
|
|||
正式会员
等级: 二袋长老
|
那么官方文件里的 //Adding a path point to a path // Appends a new PathPoint to an existing path // and initializes its anchor and handle points. if ( app.documents.length > 0 ) { var doc = app.activeDocument; var line = doc.pathItems.add(); line.stroked = true; line.setEntirePath( Array( Array(220, 475), Array(375, 300) ) ); // Append another point to the line var newPoint = doc.pathItems[0].pathPoints.add(); newPoint.anchor = Array(220, 300); newPoint.leftDirection = newPoint.anchor; newPoint.rightDirection = newPoint.anchor; newPoint.pointType = PointType.CORNER; } 运行怎么会报错呢?查找不到第一次画的直线。 不然我在这个基础上修改先画一条小短线在后面加一个点,再加一个点,再加一个点确定好锚点。也能画出弧线来。 大神来帮帮忙! |
||
2020-12-30, 13:40 | 只看该作者 #3 | |||
|
||||
VIP会员
等级: 七袋长老
|
引用:
//请参考以下代码 //////////////////////////////////////////////////////////////////////////////////////////////// #target illustrator var doc = app.activeDocument; createArc(30)//括号内输入直径,单位是mm function createArc(diaNum){ var pathItem = doc.pathItems.add(); var u=2.83464567 var dia=diaNum*u var rad=dia/2 var coe=5/3.75 var point1 = pathItem.pathPoints.add(); point1.anchor =[0,0]; point1.leftDirection = point1.anchor; point1.rightDirection =[rad*coe,0]; var point2 = pathItem.pathPoints.add(); point2.anchor = [0, dia] point2.leftDirection = [rad*coe, dia]; point2.rightDirection = point2.anchor; pathItem.stroked = true; pathItem.filled= false;} //////////////////////////////////////////////////////////////////////////////////////////////// |
|||
右列会员因为此帖价值甚高向 calvin530126 表示感谢: |
黑鸟 (2020-12-30)
|
2020-12-30, 16:06 | 只看该作者 #4 | ||
|
|||
正式会员
等级: 二袋长老
|
引用:
//#target illustrator var doc = app.activeDocument; createArc(30)//括号内输入直径,单位是mm function createArc(diaNum){ var u=2.83464567 var dia=diaNum*u //直径 var rad=dia/2 //半径 var coe=dia*0.27625 var pathItem = doc.pathItems.add(); var point1 = pathItem.pathPoints.add(); point1.anchor =[0,rad]; point1.leftDirection = point1.anchor; point1.rightDirection =[0,rad-coe]; var point2 = pathItem.pathPoints.add(); point2.anchor = [rad, 0] point2.leftDirection = [rad-coe, 0]; point2.rightDirection = [rad+coe, 0]; var point3 = pathItem.pathPoints.add(); point3.anchor = [dia, rad] point3.leftDirection = [dia,rad-coe]; point3.rightDirection = point3.anchor; pathItem.stroked = true; pathItem.filled= false; } |
||