Hi,
Is it possible to move a given anchor point from within a script? Thanks in advance.
Best regards,
Move an anchor point
Move an anchor point
Do you mean an anchor point in a path?. If so the answer is no, not really.
You can not edited paths using a script. It is possible to get all the pathPoints from a path, remove the path, and create an path from that edited info but I have done so only with simple paths with only corner points. I would think it would be much harder to move a smooth point.
You can not edited paths using a script. It is possible to get all the pathPoints from a path, remove the path, and create an path from that edited info but I have done so only with simple paths with only corner points. I would think it would be much harder to move a smooth point.
Move an anchor point
Yes, they are anchor points resulting from a text type layer converted to a shape. Also, the anchor points I want to move are corner points. Do you have a quick example of the method you described?
Move an anchor point
Here is how to edit a point on a path by it's anchor position.
Code: Select allfunction extractSubPathInfo(pathObj,oldPoint,newPoint){
var pathArray = new Array();
var pl = pathObj.subPathItems.length;
for(var s=0;s<pl;s++){
var pArray = new Array();
for(var i=0;i<pathObj.subPathItems[s].pathPoints.length;i++){
pArray = new PathPointInfo;
pArray.kind = pathObj.subPathItems[s].pathPoints.kind;
if(pathObj.subPathItems[s].pathPoints.anchor[0]==oldPoint[0] &&
pathObj.subPathItems[s].pathPoints.anchor[1]==oldPoint[1]){
pArray.anchor = newPoint;
pArray.leftDirection = newPoint;
pArray.rightDirection = newPoint;
}else{
pArray.anchor = pathObj.subPathItems[s].pathPoints.anchor;
pArray[i].leftDirection = pathObj.subPathItems[s].pathPoints[i].leftDirection;
pArray[i].rightDirection = pathObj.subPathItems[s].pathPoints[i].rightDirection;
}
};
pathArray[pathArray.length] = new Array();
pathArray[pathArray.length - 1] = new SubPathInfo();
pathArray[pathArray.length - 1].operation = pathObj.subPathItems[s].operation;
pathArray[pathArray.length - 1].closed = pathObj.subPathItems[s].closed;
pathArray[pathArray.length - 1].entireSubPath = pArray;
};
return pathArray;
};
var myPathInfo = extractSubPathInfo(app.activeDocument.pathItems.getByName('Path 1'),[334,377],[334,590]);
var myPathItem = app.activeDocument.pathItems.add("myNewPath", myPathInfo);
Code: Select allfunction extractSubPathInfo(pathObj,oldPoint,newPoint){
var pathArray = new Array();
var pl = pathObj.subPathItems.length;
for(var s=0;s<pl;s++){
var pArray = new Array();
for(var i=0;i<pathObj.subPathItems[s].pathPoints.length;i++){
pArray = new PathPointInfo;
pArray.kind = pathObj.subPathItems[s].pathPoints.kind;
if(pathObj.subPathItems[s].pathPoints.anchor[0]==oldPoint[0] &&
pathObj.subPathItems[s].pathPoints.anchor[1]==oldPoint[1]){
pArray.anchor = newPoint;
pArray.leftDirection = newPoint;
pArray.rightDirection = newPoint;
}else{
pArray.anchor = pathObj.subPathItems[s].pathPoints.anchor;
pArray[i].leftDirection = pathObj.subPathItems[s].pathPoints[i].leftDirection;
pArray[i].rightDirection = pathObj.subPathItems[s].pathPoints[i].rightDirection;
}
};
pathArray[pathArray.length] = new Array();
pathArray[pathArray.length - 1] = new SubPathInfo();
pathArray[pathArray.length - 1].operation = pathObj.subPathItems[s].operation;
pathArray[pathArray.length - 1].closed = pathObj.subPathItems[s].closed;
pathArray[pathArray.length - 1].entireSubPath = pArray;
};
return pathArray;
};
var myPathInfo = extractSubPathInfo(app.activeDocument.pathItems.getByName('Path 1'),[334,377],[334,590]);
var myPathItem = app.activeDocument.pathItems.add("myNewPath", myPathInfo);