Here's the scenario that I and my coworkers are trying to resolve. I'm sorry that this is so long, but it seems that this is a very difficult problem to describe. I haven't been very successful describing the problem (as I perceive it) to the folks I work with. Hopefully I'll do better here.
In the construction plans that we create we use xrefs. Lots of xrefs. On the xrefs we use blocks, some big block and some little block -- lots of little blocks. The little blocks have attributes that we use for things like pipe sizes, wire sizes, and notes.
When we turn the plans into drawings, we cut the xrefs up using viewports in paper space, and stick the viewports on pages with title blocks. Then we run an AutoLisp program that finds particular blocks on that drawing, and then the program creates a database of the block attributes. Back in the "old days" it was easy -- you just make a selection set of all the blocks with a particular name and extract the attributes.
However, since xrefs and viewports have come along things have gotten increasingly complicated. There are a LOT of blocks in each "dwg" file that we don't want to find. In order to sift those out, our AutoLisp program has been doing all this stuff:
1. Finding a viewport.
2. Saving the coordinates of the viewport.
3. Binding and exploding the xrefs.
4. Finding the desired blocks inside a polygon defined by the saved coordinates of the viewport.
5. Creating a selection set of those blocks.
6. Repeating this for each viewport.
7. UNDO, UNDO, UNDO, ETC until we get the drawing back to a stable state.
As you can see this is very, VERY cumbersome. To make matters worse, the drawings are getting bigger and bigger, and we tend to have multiple xrefs in a drawing. Frequently the computer will completely crash. Sometimes it even screws up the drawings so much that they have to be "recovered."
There simply HAS to be a better way.
What we need is some mechanism to create, in AutoLisp, a selection set of a particular block that is VISIBLE IN THE CURRENT SPACE. I don't care if the block is inserted directly on the drawing, nested deep in xrefs, in a block, in paper space, in model space, I DON'T CARE, but if it is VISIBLE it needs to wind up in the selection set.
If a block is on a frozen layer, on a layer that isn't displayed, outside a viewport, or not displayed for any reason it should NOT be in the selection set.
This has proven to be very elusive. We've tried the "EATTEXT" method, but it is hard to use in AutoLisp and it gives you all the blocks that are in any xref, visible or not. We've tried getting all the blocks and then checking their coordinates, but the math quickly gets out of hand and it's very hard to compare coordinates in the "universe" to those of the "viewport."
I keep telling myself we're missing something really simple, and I'm hopeful that somebody can point us in the right direction.
I'm also hoping that this will make sense.
Thanks!
Wayne.