Skip to content

Instantly share code, notes, and snippets.

@nicoptere
Last active May 30, 2018 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicoptere/627126178002f8a50d551b3cfa8fa18d to your computer and use it in GitHub Desktop.
Save nicoptere/627126178002f8a50d551b3cfa8fa18d to your computer and use it in GitHub Desktop.
this will remove illustrator paths under a given length ( to clean up smaller paths basically )
#target illustrator
var document = app.activeDocument;
var maxLength = prompt ("maximum length of a path", 10, "destroy them with lasers!");
for (i=0 ; i< document.pathItems.length; i++)
{
var ipath = document.pathItems[i]
if( ipath.hidden == true )continue;
var l = 0;
for( var j = 0; j < ipath.pathPoints.length - 1; j++ ){
var p0 = ipath.pathPoints[j].anchor;
var p1 = ipath.pathPoints[j+1].anchor;
var dx = p0[0] - p1[0];
var dy = p0[1] - p1[1];
l += Math.sqrt( dx*dx + dy*dy );
if( l > maxLength )break;
}
if( l < maxLength )
{
try{
ipath.selected = true;
}
catch( e ){
//meh...
}
}
}
app.redraw();
if(confirm ("erase?", "yes", "my finger is on the button..."))
{
app.cut();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment