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

Select Points Along a Y Axis

Engaged ,
Sep 10, 2018 Sep 10, 2018

Hello,

Is there a simple solution via a JavaScript that would allow me to (once I have selected a point) automatically select all of the points that land on that same

Y-Axis?

Capture.PNG

Possibly even adding points to paths on that same Y-Axis (like in the case of the S in the attached image)?

I am hoping to copy them, move them by .125 below and convert them to rectangles.

I am able to do all of this with an action but the first step.

Any help would be great thank you!

TOPICS
Scripting
1.1K
Translate
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

Valorous Hero , Sep 11, 2018 Sep 11, 2018

So you want something like this ?

#target illustrator

function test(){

    var doc = app.activeDocument;

    var selectedItem = doc.selection[0];

    var selectedPoints = selectedItem.selectedPathPoints;

    var selectedPoint;

    var tolerance = 2;

    for(var i = 0; i < selectedPoints.length; i++){

        if(selectedPoints.selected == PathPointSelection.ANCHORPOINT){

          selectedPoint =  selectedPoints;

        }

    };

    var sampleY = selectedPoint.anchor[1];

    selectedPoint.selected

...
Translate
Adobe
Valorous Hero ,
Sep 10, 2018 Sep 10, 2018

Yea you can try this!

Change the tolerance to include more points along a wider buffer area.

#target illustrator

function test(){

    var doc = app.activeDocument;

    var selectedItem = doc.selection[0];

    var selectedPoints = selectedItem.selectedPathPoints;

    var selectedPoint;

    var tolerance = 2;

    for(var i = 0; i < selectedPoints.length; i++){

        if(selectedPoints.selected == PathPointSelection.ANCHORPOINT){

          selectedPoint =  selectedPoints;

        }

    };

    var thisPath, thisPathPoint;

    for(var i = 0; i < doc.pathItems.length; i++){

        thisPath = doc.pathItems;

        for(var j = 0; j < thisPath.pathPoints.length; j++){

            thisPathPoint = thisPath.pathPoints;

            if(

                (thisPathPoint.anchor[1] - tolerance <= selectedPoint.anchor[1] && thisPathPoint.anchor[1] + tolerance >= selectedPoint.anchor[1])

            ){

                thisPathPoint.selected = PathPointSelection.ANCHORPOINT;

            }

        };

    };

};

test();

Translate
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
Engaged ,
Sep 11, 2018 Sep 11, 2018

This is great!  Thank you!

Translate
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
Engaged ,
Sep 11, 2018 Sep 11, 2018

It's exactly what I asked for but Illustrator did not function the way I was expecting.  So it looks like I'm going to have to tackle this a bit differently. 

Translate
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
Valorous Hero ,
Sep 11, 2018 Sep 11, 2018

Oh no! So what was it doing?

Translate
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
Engaged ,
Sep 11, 2018 Sep 11, 2018

The Script is doing nothing wrong  I'm just ending up with extra line segments.  It's almost like I need it to select all of the points -except- the ones on the Y-axis so I can delete them away.Capture.PNG

and end up with this.

Capture2.PNG

Translate
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
Valorous Hero ,
Sep 11, 2018 Sep 11, 2018

So you want something like this ?

#target illustrator

function test(){

    var doc = app.activeDocument;

    var selectedItem = doc.selection[0];

    var selectedPoints = selectedItem.selectedPathPoints;

    var selectedPoint;

    var tolerance = 2;

    for(var i = 0; i < selectedPoints.length; i++){

        if(selectedPoints.selected == PathPointSelection.ANCHORPOINT){

          selectedPoint =  selectedPoints;

        }

    };

    var sampleY = selectedPoint.anchor[1];

    selectedPoint.selected = PathPointSelection.NOSELECTION;

    var thisPath, thisPathPoint;

    for(var i = 0; i < doc.pathItems.length; i++){

        thisPath = doc.pathItems;

        for(var j = 0; j < thisPath.pathPoints.length; j++){

            thisPathPoint = thisPath.pathPoints;

            if(

                !(thisPathPoint.anchor[1] - tolerance <= sampleY && thisPathPoint.anchor[1] + tolerance >= sampleY)

            ){

                thisPathPoint.selected = PathPointSelection.ANCHORPOINT;

            }

        };

    };

};

test();

Translate
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 ,
Sep 12, 2018 Sep 12, 2018

Your script is useful

Thanks for dedication

Translate
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 ,
Sep 12, 2018 Sep 12, 2018
Translate
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
Valorous Hero ,
Sep 12, 2018 Sep 12, 2018

Sorry, the work entailed for accomplishing your task is more involved than some of the simpler snippets and unfortunately I'm quite booked up at the moment with some clients. Perhaps another contributor can help you out, and maybe I may get some chance to take a break and analyze your problem further - but this time may be some weeks in duration.


However, I can set you on the path to the simplest way this could be done. You will need to use one of the scripts found on this forum which can apply a character style via regular expression, because you will need to find each of your spaces and style them differently, such as with a different character color.

The trick to avoid work is, to use the Flatten Transparency command to accomplish your task! When you have an area text and use Flatten Transparency, but without "Convert text to outlines" checked, it will make each line in your area text into point text and it would also create breaks in the point text where the spaces used to be - provided you have indeed colored each whitespace character with a color different from the normal character color.

Translate
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
Engaged ,
Sep 12, 2018 Sep 12, 2018
LATEST

Silly-V,

Sorry to ask but is there a way to automatically select an Anchor Point?  It will always be the Lowest point (and because there will be multiple on that Y-axis I choose the Left most point.

If not or it would add substantially more scripting I completely understand and with work with what you have already given me

Thank you again for the assist!

Translate
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