# How to select all Smooth pathPoints that have two handles aligned at horizontal or vertical axis?

Explorer ,
Apr 27, 2021 Apr 27, 2021

Copied

How to select all Smooth pathPoints that have two handles aligned at horizontal or vertical axis? Via scripting.

Thanks!

TOPICS
Draw and design, Scripting

Views

94

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Enthusiast , Apr 27, 2021 Apr 27, 2021
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...

Likes

6 Replies 6
Apr 27, 2021 Apr 27, 2021

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
}
else if(myPoint.leftDirection[0] === myPoint.rightDirection[0])
{
}
else if(myPoint.leftDirection[1] === myPoint.rightDirection[1])
{
}
``````

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copied

Thanks, DilliamWowling, but your code not works for me. Maybe i'm doing something wrong.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 27, 2021 Apr 27, 2021

Copied

my comment was intended to be educational, not functional. I was showing you how to accomplish what you want to do.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copied

LATEST

Thanks, DilliamWowling, my JavaScript programming skills are very limited.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Enthusiast ,
Apr 27, 2021 Apr 27, 2021

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;
}
}
}``````

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copied

Works! Thanks! femkeblanco

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Learning Resources for Illustrator
What's new and fixed in Illustrator
Fonts and Typography in Illustrator