Last active
May 30, 2018 20:59
-
-
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 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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