Is there some way to distinguish which "blocks" are gridlines? Something like a layer - or perhaps something like a portion of their block-name?
E.g. say they're on a layer called something with "GRID" inside it, you can select all the blocks not on those layers like so:
Code:
(if (setq BlocksToExplode (ssget "_X" '((0 . "INSERT") (8 . "~*GRID*"))))
(command "_.EXPLODE" BlocksToExplode "")
)
The first line selects everything in the drawing (ssget "_X" ... but filters only for block inserts (0 . "INSERT") and layer not with GRID in it (8 . "~*GRID*"). To see the DXF codes refer to the developer help on them: http://docs.autodesk.com/ACD/2011/EN...a0ab7-5df0.htm
The the 2nd line simply sends that selection set to the explode command.
Then to erase everything on layer 0:
Code:
(if (setq EntitiesOn0 (ssget "_X" '((8 . "0"))))
(command "_.ERASE" EntitiesOn0 "")
)
To select blocks with "*E*" in their name:
Code:
(if (setq BlocksWithE (ssget "_X" '((0 . "INSERT") (2 . "*E*"))))
(command "_.ERASE" BlocksWithE "")
)
I wrapped all the selections in ifs, so that the command only runs if there are actually objects found to select.