what?? a new document function?? I'm not kidding CS5 DOM has a new function!!! I know...it is hard to believe. And with it, new doors seem to open, like testing if a path intersects little yellow squares...no math required.
selectObjectsOnActiveArtboard() //
#target Illustrator
/* loops thru all objects to test for intersection with
a path (path must be top object), start with nothing
selected. Script assumes, 1 artboard.
*/
var idoc = app.activeDocument;
var yellowSq = idoc.pathItem;
var abRect = idoc.artboards[0].artboardRect;
var tempRect = abRect;
var yellowSqs = [];
for (i=1;i<=idoc.pathItems.length-1;i++)
{
yellowSq = idoc.pathItems;
idoc.artboards[0].artboardRect = yellowSq.visibleBounds;
idoc.selectObjectsOnActiveArtboard();
if (idoc.pathItems[0].selected)
{
//alert ("yes!!");
yellowSq.fillColor = idoc.swatches["White"].color;
yellowSqs.push(yellowSq);
}
idoc.pathItems[0].selected = false;
yellowSq.selected = false;
}
idoc.artboards[0].artboardRect = tempRect;
alert("the green line intersects " + yellowSqs.length + " yellow squares");

update: added snapshot
Message was edited by: CarlosCanto