Here is a bit of code to change the blocks that have been changed from the Express Tools Flatten command. This will replace the "flatten"ed blocks to the original block definition (without the *-flat-* block name) before the flatten command was executed on the blocks., as long as the original block definition is still within the drawing.
Originally Posted by pangell
Let me know if you have any problems with this. It does not contain any error handling. It has been tested, but only a little.
(defun C:FIXAFLAT ()
(setq SSET (ssget "x" (list (cons 2 "*-flat-*")))
(repeat (sslength SSET)
(setq ENTITY (entget (ssname SSET CNT))
BNAME (cdr (assoc 2 ENTITY))
BNAMECNT (vl-string-search "-flat-" BNAME 0)
BNAMEBASE (substr BNAME 1 BNAMECNT)
CNT (1+ CNT)
(if (tblsearch "BLOCK" BNAMEBASE)
(setq ENTITY (subst (cons 2 BNAMEBASE) (assoc 2 ENTITY) ENTITY))
(command "_purge" "Blocks" bname "No")
(while (= 1 (getvar "cmdactive"))