• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

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

347

Translate

Translate

Report

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

correct answers 1 Correct answer

Guide , 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
...

Votes

Translate

Translate
Adobe
Community Expert ,
Apr 27, 2021 Apr 27, 2021

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");
}

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Works! Thanks! femkeblanco

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 31, 2021 Aug 31, 2021

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.

SelectPointsByType.gif

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

LATEST

Thanks, Sergey, your scripts are awesome.

Votes

Translate

Translate

Report

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