Skip to content

Instantly share code, notes, and snippets.

@nicoptere
Last active May 30, 2018 20:59
Show Gist options
  • Save nicoptere/627126178002f8a50d551b3cfa8fa18d to your computer and use it in GitHub Desktop.
Save nicoptere/627126178002f8a50d551b3cfa8fa18d to your computer and use it in GitHub Desktop.

Revisions

  1. nicoptere revised this gist May 30, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions remove small paths in illustrator
    Original file line number Diff line number Diff line change
    @@ -12,10 +12,16 @@ for (i=0 ; i< document.pathItems.length; i++)
    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();
  2. nicoptere created this gist May 30, 2018.
    25 changes: 25 additions & 0 deletions remove small paths in illustrator
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #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 )
    {
    ipath.selected = true;
    }
    }
    app.redraw();
    if(confirm ("erase?", "yes", "my finger is on the button..."))
    {
    app.cut();
    }