3

I am simplifying a design in Illustrator and already ran Path > Simplify and Path > Clean Up. I have many paths with small areas or small perimeters that I would like to select and delete. I can do it programmatically with an SVG version of the design and Inkscape; but I would rather use Illustrator and see the result as I delete those areas.

Can Illustrator select paths by area or perimeter?

1 Answer 1

4

Install the following script with these directions, then run it and adjust the parameter 100 as needed:


#target illustrator


var doc = app.activeDocument;
var objs = doc.pageItems;
traverseSceneObjects(objs, selectByCurveLengthFactory(100));
redraw();

function selectByCurveLengthFactory( length){
    return function(item) {
        if ( item.length <=  length)
        {
           item.selected = true;
        }
    }
}


function traverseSceneObjects(pageItems, func){

    for (var iter=0 ; iter<pageItems.length; iter++ ){
        var item = pageItems[iter];
        var typename = item.typename;

        // apply action or get the subitems of object
        if (typename === "PathItem"){
            func(item);

        } else if (typename === "GroupItem") {
            traverseSceneObjects( item.pageItems, func );

        } else if (typename === "CompoundPathItem" ) {
            traverseSceneObjects( item.pathItems, func );
        }
    }
}
1
  • This fails when layers are hidden. Could you add code to skip those? And to to prompt the user for the the threshold of selection? Thanks!
    – emonigma
    Commented Mar 2, 2020 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.