Copy link to clipboard
Copied
How to select all Smooth pathPoints that have two handles aligned at horizontal or vertical axis? Via scripting.
Thanks!
var paths = app.activeDocument.pathItems;
for (var i = 0; i < paths.length; i++) {
var points = paths[i].pathPoints;
for (var j = 0; j < points.length; j++) {
var x = points[j].anchor[0], y = points[j].anchor[1];
var Rx = points[j].rightDirection[0], Ry = points[j].rightDirection[1];
var Lx = points[j].leftDirection[0], Ly = points[j].leftDirection[1];
if ((Rx == Lx && Ry != Ly) || (Ry == Ly && Rx != Lx)) {
points[j].selected = PathPointSelecti
...
Copy link to clipboard
Copied
each pathPoint has 2 properties called leftDirection and rightDirection each of which hold an array of 2 numbers representing the (x,y) position of the end of the control handle. if the "left" or "x" coordinate of both left/rightDirection are the same, then they're aligned vertically. If the "top" or "y" coordinate of both left/rightDirection are the same, they're aligned horizontally.
var myPath = app.activeDocument.pathItems[0];
myPoint = myPath.pathPoints[0];
if(myPoint.pointType === PointType.CORNER)
{
//probably skip this point since it can never be
//the type of smooth edge point you're looking for
alert("this is a corner point.");
}
else if(myPoint.leftDirection[0] === myPoint.rightDirection[0])
{
alert("handles are aligned vertically");
}
else if(myPoint.leftDirection[1] === myPoint.rightDirection[1])
{
alert("handles are aligned horizontally");
}
Copy link to clipboard
Copied
Thanks, DilliamWowling, but your code not works for me. Maybe i'm doing something wrong.
Copy link to clipboard
Copied
my comment was intended to be educational, not functional. I was showing you how to accomplish what you want to do.
Copy link to clipboard
Copied
Thanks, DilliamWowling, my JavaScript programming skills are very limited.
Copy link to clipboard
Copied
var paths = app.activeDocument.pathItems;
for (var i = 0; i < paths.length; i++) {
var points = paths[i].pathPoints;
for (var j = 0; j < points.length; j++) {
var x = points[j].anchor[0], y = points[j].anchor[1];
var Rx = points[j].rightDirection[0], Ry = points[j].rightDirection[1];
var Lx = points[j].leftDirection[0], Ly = points[j].leftDirection[1];
if ((Rx == Lx && Ry != Ly) || (Ry == Ly && Rx != Lx)) {
points[j].selected = PathPointSelection.ANCHORPOINT;
}
}
}
Copy link to clipboard
Copied
Works! Thanks! femkeblanco
Copy link to clipboard
Copied
I added these points to my free SelectPointsByType script and called them Ortho points. It also allows you to select many other interesting point types on paths.
Copy link to clipboard
Copied
Thanks, Sergey, your scripts are awesome.