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

Selecting a Single Point of a Script

Community Beginner ,
Sep 07, 2023 Sep 07, 2023

There are single points in the drawings from Autocad. Is there a script to select only these single points?

 

Thank you!

TOPICS
Scripting
445
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 , Sep 07, 2023 Sep 07, 2023

Not tested. Save before trying.

var paths = app.activeDocument.pathItems;
for (var i = paths.length - 1; i > - 1; i--) {
    if (paths[i].pathPoints.length <= 2) {
        var ps = paths[i].pathPoints;
        if (ps[0].anchor.toString() == ps[1].anchor.toString() && 
            ps[0].rightDirection.toString() == ps[1].rightDirection.toString() && 
            ps[0].leftDirection.toString() == ps[1].leftDirection.toString()) {
                paths[i].remove();
        }
    }
}
Translate
Adobe
Community Expert ,
Sep 07, 2023 Sep 07, 2023

THis is even built into Illustrator. You could check out Select > Object > Single anchor points. 

Or use the Object > Path > Clean up function.

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 Beginner ,
Sep 07, 2023 Sep 07, 2023

Thank but "Object > Path > Clean up function" I tried but it didn't work. I couldn't find "Select > Object > Single anchor points". Is there a different method?

 

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 ,
Sep 07, 2023 Sep 07, 2023

I don't think they are single points; especially the one on the right since Illustrator will not display a stroke on a single point like that. Try drag one with the direct select tool and see what happens. There may be two connected points on top of each other, so in essence a line segment (which makes sense for Autocad). In which case the Clean Up tool will not find them.

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 Beginner ,
Sep 07, 2023 Sep 07, 2023

I checked, single point.

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 ,
Sep 07, 2023 Sep 07, 2023

How did you check? In the Document info panel?

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 ,
Sep 07, 2023 Sep 07, 2023

Not tested. Save before trying.

var paths = app.activeDocument.pathItems;
for (var i = paths.length - 1; i > - 1; i--) {
    if (paths[i].pathPoints.length <= 2) {
        var ps = paths[i].pathPoints;
        if (ps[0].anchor.toString() == ps[1].anchor.toString() && 
            ps[0].rightDirection.toString() == ps[1].rightDirection.toString() && 
            ps[0].leftDirection.toString() == ps[1].leftDirection.toString()) {
                paths[i].remove();
        }
    }
}
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 Beginner ,
Sep 07, 2023 Sep 07, 2023
LATEST

This script perfect working cleared all single points. 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