I'm trying to write a LISP which will determine which blocks are next to or attached to the current block on each side seperately, in order to automate the 'joining' part of plotting our network plans.
I have a selection set containing the middle block. On each side of the block there is another block.
Is there any way to determine which block is directly attached to the right/left/top/bottom side of my selection? The blocks are rectangular and slot together to form a grid, each one is plotted to a seperate sheet and we want to write 'joins plan X' on each side of the sheet where there is a joining plan.
I had a thought of creating a bounding box, expanding it one pixel to the right, one in from the top/left/bottom and then grabbing objects inside that box - is there a more elegant way to achieve this?
Thanks in advance!
@dy_lan wrote:
I'm trying to write a LISP which will determine which blocks are next to or attached to the current block on each side seperately, in order to automate the 'joining' part of plotting our network plans.
Attached = nested inside a block?
Next= Adjacent to?
or are they pertainng to the same thing? as "right beside" <top/left/bottom/right> ?
@dy_lan wrote:
....
Is there any way to determine which block is directly attached to the right/left/top/bottom side of my selection? The blocks are rectangular ....
If they are actually touching, you should be able to get the corners of the bounding box of the selected one, and use that in an (ssget) function as a Crossing window to select adjacent ones. Do you know how to set that up?
By the way, welcome to these Forums!
@dy_lan wrote:
The boxes are rectangles, inserted so the top-left point snaps to the top-right point - so if the top-right point of a box matches the top-left point, that box is 'to the right' - if the bottom-left matches the top-left, that box is 'on top' etc. However, I couldn't figure out how to get the exactly top-left and bottom-right of all the boxes in order to find out which one matches...
....As you can probably see in the script above, my solution was to move the point to the middle of the bottom line of the box so that it'd only return the two boxes, then put the 'selected box' into back and return the first (front) result of the match. It kinda works, but I get the sense there's a much, much better way to be doing this!
I'd rather see a sample drawing than try to understand what you meant by the statement above dy_lan.