Skip to main content
Inspiring
February 23, 2017
Answered

Select by area size or path length?

  • February 23, 2017
  • 2 replies
  • 4109 views

Is there a script or plug-in that would allow the selection of objects that are above or below a certain threshold for area size or path length?

For example, I want to select and delete all objects that have an area of less than 1 mm². Or a path length less than 1mm.

Or just select paths that are over 1000mm long or more than 1000 mm² in size?

(Running CC2017 / Mac)

This topic has been closed for replies.
Correct answer Larry G. Schneider

You could try this

#target illustrator

// deletes pathItems smaller than the supplied length

var idoc = app.activeDocument;

var howLong = prompt ("Enter the size in points of small paths to be deleted", 2, "Delete Small Paths");

for (i=0 ; i< idoc.pathItems.length; i++)

     {

          var ipath = idoc.pathItems

               if ( ipath.width < howLong && ipath.height < howLong)

                    {

                         ipath.selected = true;

                    }

     }

app.redraw();

if(confirm ("Proceed to delete selected items?", "yes", "Confirm Delete"))

     {

          app.cut();

     }

2 replies

CarlosCanto
Community Expert
Community Expert
April 26, 2020

all scripts got messed up when we migrated to the new Forums 😞

Larry G. Schneider
Community Expert
Larry G. SchneiderCommunity ExpertCorrect answer
Community Expert
February 23, 2017

You could try this

#target illustrator

// deletes pathItems smaller than the supplied length

var idoc = app.activeDocument;

var howLong = prompt ("Enter the size in points of small paths to be deleted", 2, "Delete Small Paths");

for (i=0 ; i< idoc.pathItems.length; i++)

     {

          var ipath = idoc.pathItems

               if ( ipath.width < howLong && ipath.height < howLong)

                    {

                         ipath.selected = true;

                    }

     }

app.redraw();

if(confirm ("Proceed to delete selected items?", "yes", "Confirm Delete"))

     {

          app.cut();

     }

shamp_ton
Participant
April 26, 2020

This script has a bug - 

var ipath = idoc.pathItems

should be

var ipath = idoc.pathItems[i];