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

Java Script: How select all corner points?

Explorer ,
Jul 03, 2015 Jul 03, 2015

Java Script: How select all corner points in opened document?

TOPICS
Scripting
1.5K
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

Guide , Jul 05, 2015 Jul 05, 2015

this may do what you are after.

*****Do Not expect this to work on complex paths.*****

very tight tolerance set, this can be changed if smooth does not need to be too smooth.

//------------------------------------------------------------------------------------

//          Select "Sharp" or "Smooth" pathPoints

//------------------------------------------------------------------------------------

//

//          Qwertyfly

//          06/07/2015

//          Version 1.0

//

//--------------------------

...
Translate
Adobe
Community Expert ,
Jul 03, 2015 Jul 03, 2015

Hi victorcarbajo‌,

hmmh?

1. Why and what exactly? (number of corner points or position or corner point kinds)

2. Your illustrator version?

3. A sample document?

4. Are there deep nested grouped groups in your document? Or nested compound paths? Or areas – defined in the appearance palette?

5. What is with hidden paths or clipping paths?

6. How many paths exists in your document?

But anyway – this will give you the number of Path points of the first path item in your document:

alert (app.activeDocument.pathItems[0].pathPoints.length)

Have fun

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 ,
Jul 03, 2015 Jul 03, 2015

Example:

example.png

Result of script:

result of script.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
Community Expert ,
Jul 03, 2015 Jul 03, 2015

Why do you not answers to my questions?

Anyway, this will select the first path point of the first path item in your document:

app.activeDocument.pathItems[0].pathPoints[0].selected = PathPointSelection.ANCHORPOINT;

Have fun

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 ,
Jul 03, 2015 Jul 03, 2015

Thanks, pixxxel schubser, for your answer. Excuse my delay.

My Illustrator version is 19.0.0.

There are not nested grouped groups in my document. There are not nested compound paths. Only simple paths with curve and corner points, but the document have a lot of paths. I need to modify corner points together, and then curve points together.

With best regards.

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
Community Expert ,
Jul 04, 2015 Jul 04, 2015

Thanx for your answer.

But again:

What do you want to do exactly with the selected corner points or selected curved points?

The background of this question is: a loop through all path items takes a long time – more path items, more longer! Additional you have to loop through all path points of every path item. The takes again more time! And that's why: What do you want to do exactly with the selected corner points or selected curved points?

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 ,
Jul 04, 2015 Jul 04, 2015

I need to modify corner points together and curve points together for two reasons:

1. When I vectorizing my hand drawings I found a lot of mistake points. I selected the points by hand, but it take a lot of time.

2. I explore the possibilities of this two worlds (corner and curve points) when I freely draw in Illustrator.

With best regards.

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
Community Expert ,
Jul 04, 2015 Jul 04, 2015

So we will not get. We turn in circles. Imagine, I  am 5 year old and you want to tell me what exactly you are doing.

Please define "mistake points".

Please give an example file (CS3 or at max CS5 compatible).

An automatic vectorization generates countless paths.

What criteria do you choose your path points (manually) from? What exactly do you do with the path points after selection???

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 ,
Jul 04, 2015 Jul 04, 2015

Dear pixxxel schubser,

I uploaded a Illustrator CS3 file with "mistake points". Link: mistake_points.ai - Box

In this file most points have abnormal behavior. I could correct this abnormal behavior if I could select them and modify with, for example, InkScribe plug-in. Now I make this operation manually.

With best regards.

PS: Excuse my English, I am Spanish and maybe I do not understand me well.

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
Guide ,
Jul 05, 2015 Jul 05, 2015

this may do what you are after.

*****Do Not expect this to work on complex paths.*****

very tight tolerance set, this can be changed if smooth does not need to be too smooth.

//------------------------------------------------------------------------------------

//          Select "Sharp" or "Smooth" pathPoints

//------------------------------------------------------------------------------------

//

//          Qwertyfly

//          06/07/2015

//          Version 1.0

//

//------------------------------------------------------------------------------------

//

//          *****Do Not expect this to work on complex paths.*****

//

//------------------------------------------------------------------------------------

//

//          Set tolerance here (this is in Radians)

var tolerance = 0.0000000001;

//

//------------------------------------------------------------------------------------

var doc = app.activeDocument;

var myPoint, angle1, angle2, sel = "";

var w = new Window('dialog');

var B1 = w.add('button',undefined,"Select Corner Anchors");

var B2 = w.add('button',undefined,"Select Smooth Anchors");

var B3 = w.add('button',undefined,"Cancel");

B1.onClick = function(){sel = "sharp"; goTime();}

B2.onClick = function(){sel = "smooth"; goTime();}

B3.onClick = function(){w.close()}

w.show()

function goTime(){

    w.close();

    doc.selection = null;

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

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

            myPoint = doc.pathItems.pathPoints;

            if(sel == "smooth"){

                if(isSmooth()){

                    myPoint.selected = PathPointSelection.ANCHORPOINT;

                }

            }else if(sel == "sharp"){

                if(!isSmooth()){

                    myPoint.selected = PathPointSelection.ANCHORPOINT;

                }

            }else{alert("error");}

        }

    }

}

function isSmooth(){

    angle1 = Math.atan2(myPoint.leftDirection[1] - myPoint.anchor[1],myPoint.leftDirection[0] - myPoint.anchor[0]);

    angle2 = Math.atan2(myPoint.rightDirection[1] - myPoint.anchor[1],myPoint.rightDirection[0] - myPoint.anchor[0]);

    return(Math.abs((angle1 - angle2)) > Math.PI - tolerance && Math.abs((angle1 - angle2)) < Math.PI + tolerance);

}

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
Guide ,
Jul 05, 2015 Jul 05, 2015

for your .ai I needed to drop the tolerance to "0.01"

then it worked

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 ,
Jul 06, 2015 Jul 06, 2015

Fantastic! Works!

Thanks for your brain, Qwertyfly..., it is a awesome script.

With best wishes.

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
Guide ,
Jul 06, 2015 Jul 06, 2015
LATEST

‌glad I could help!

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