//############################################################# // RemoveItemsbelow V1.0 - 31/08/2010 // Remove any items whose width and height is below the values set in the dialog fields // Enter width and height as single numbers without unit (ie 5 and not 5mm) // Tested on Illustrator CS4 // Bugs and feedbacks : loic(dot)aigon(at)gmail(dot)com //############################################################# function removeItemsBelow(doc,w,h){ w = Number(w); h=Number(h); if(w==0 && h==0){ return false } switch(doc.rulerUnits){ case RulerUnits.Picas: w=w*12; h=h*12; break; case RulerUnits.Inches: w=w*72; h=h*72; break; case RulerUnits.Millimeters: w=w*2.834; h=h*2.834; break; case RulerUnits.Centimeters: w=w*28.347; h=h*28.347; break; } var pi=doc.pathItems; var piLg = pi.length; var c1, c2; for(var i =piLg-1; i>=0; i--){ var piw = pi[i].width; var pih = pi[i].height; var c1 = (w!=0)? piw0){ removeWindow(doc); } } function removeWindow(doc){ var w = new Window('dialog',"",undefined); w.preferredSize = [100,150]; w.orientation='column'; w.add('statictext',undefined,'Remove items below'); var widthGp = w.add('group'); widthGp.orientation='row'; widthGp.add('statictext',undefined,'Width'); var enteredW = widthGp.add('edittext'); enteredW.preferredSize.width=50; enteredW.onChange = function(){ if(isNaN(enteredW.text)){ alert("No valid number"); enteredW.text=""; enteredW.active=true; } } var heightGp = w.add('group'); heightGp.orientation='row'; heightGp.add('statictext',undefined,'Height'); var enteredH = heightGp.add('edittext'); enteredH.preferredSize.width=50; enteredH.onChange = function(){ if(isNaN(enteredW.text)){ alert("No valid number"); enteredH.text=""; enteredH.active=true; } } var btnGp = w.add('group'); var btn = btnGp.add('button',undefined,'Remove'); btn.onClick = function(){ removeItemsBelow(doc,enteredW.text,enteredH.text); w.close(); } w.add('statictext',undefined,'www.loicaigon.com'); w.show(); } app.main();