0
Adobe Illustrator 스크립팅을 위해 ExtendScript를 사용하고 있습니다. 프로그래밍 방식으로 캡처 한 다음 경로 모양을 복제 할 수있는 비열한 방법이나 스크립트가 있는지 궁금 해서요. JavaScript의 일종 인 .toSource()
에 해당하는 것입니다.Ai 경로 모양을 프로그래밍 방식으로 캡처하고 복제하려면 어떻게합니까?
감사
Adobe Illustrator 스크립팅을 위해 ExtendScript를 사용하고 있습니다. 프로그래밍 방식으로 캡처 한 다음 경로 모양을 복제 할 수있는 비열한 방법이나 스크립트가 있는지 궁금 해서요. JavaScript의 일종 인 .toSource()
에 해당하는 것입니다.Ai 경로 모양을 프로그래밍 방식으로 캡처하고 복제하려면 어떻게합니까?
감사
이 시도 :
main();
function main(){
var doc = app.activeDocument; // get the active doc
var coords = new Array(); // make a new array for the coords of the path
var directions = new Array();
var sel = doc.selection[0];// get first object in selection
if(sel == null) {
// check if something is slected
alert ("You need to sevlect a path");
return;
}
var points = sel.pathPoints;// isolate pathpoints
// loop points
for (var i = 0; i < points.length; i++) {
// this could be done in one lines
// just to see whats going on line like
//~ coords.push(new Array(points[i].anchor[0],points[i].anchor[1]));
var p = points[i]; // the point
var a = p.anchor; // his anchor
var px = a[0];// x
var py = a[1]; // y
var ldir = p.leftDirection;
var rdir = p.rightDirection;
directions.push(new Array(ldir,rdir));
coords.push(new Array(px,py));// push into new array of array
}
var new_path = doc.pathItems.add(); // add a new pathitem
new_path.setEntirePath(coords);// now build the path
// check if path was closed
if(sel.closed){
new_path.closed = true;
}
// set the left and right directions
for(var j = 0; j < new_path.pathPoints.length;j++){
new_path.pathPoints[j].leftDirection = directions[j][0];
new_path.pathPoints[j].rightDirection = directions[j][1];
}
}