i have this one i use from time to time
;| BLKSWP.LSP c.2000 Rob Herr robherr@hotmail.com
'Swap Blocks Globally' v 2.0 28 Mar 2000
Pick one block. Pick one other block. Each instance of these blocks
are switched throughout the drawing. Not recommended for attributes,
unless blocks have complementary attribute locations, etc.
___________________________________________________________________
| PERMISSION HEREBY GRANTED BLA, BLA, BLA, TO MODIFY ETC. |
| As long as name and email remain with the original program |
| unaltered. However I would like to know of any bugs or problems |
| that arise with the actual program. And of course I take no |
| responsibility for lost limbs, auto repair bills, mechanical |
| or electronic difficulties, or snake venom. |
-------------------------------------------------------------------
v1.1 added osnap control
v1.2 added attribute exclusion
v2.0 changed routine from 'reinsertion' to 'redefine xdata'
and removed attribute exclusion
|;
(defun C:blkswp (/ osm a1 b1 a2 a3 aasc an aset alen b2 b3 basc bn
bset blen cnt anxt anfo bnxt bnfo)
(setvar "CMDECHO" 0)
(setq osm (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq a1 (entsel "\nSelect Block to Swap..."))
(setq b1 (entsel "\nSelect Block to Swap with..."))
(command "REGENAUTO" "Off")
(setq a2 (car a1))
(setq a3 (entget a2))
(if (= (cdr (assoc 0 a3)) "INSERT")
(progn
(setq aasc (assoc '2 a3))
(setq an (cdr aasc))
(setq aasc (list aasc))
(setq aset (ssget "X" aasc))
(setq alen (sslength aset))
(princ "\nUpdating blocks...")
)
(progn
(setq aset nil)
(setvar "OSMODE" osm)
(setvar "CMDECHO" 1)
(princ "\nThat is not a block! ")
(exit)
)
)
(setq b2 (car b1))
(setq b3 (entget b2))
(if (= (cdr (assoc 0 b3)) "INSERT")
(progn
(setq basc (assoc '2 b3))
(setq bn (cdr basc))
(setq basc (list basc))
(setq bset (ssget "X" basc))
(setq blen (sslength bset))
(princ "\nUpdating blocks...")
)
(progn
(setq bset nil)
(setvar "OSMODE" osm)
(setvar "CMDECHO" 1)
(princ "\nThat is not a block! ")
(exit)
)
)
(setq cnt 0)
(while (< cnt alen)
(setq anxt (ssname aset cnt))
(setq anfo (entget anxt))
(if (= (cdr (assoc 0 anfo)) "INSERT")
(progn
(setq anfo (subst (cons 2 bn) (assoc 41 anfo) anfo))
(entmod anfo)
(entupd anxt)
);progn
(princ "\nA Block was not Selected! ")
);if
(setq cnt (1+ cnt))
);end while
(setq cnt 0)
(while (< cnt blen)
(setq bnxt (ssname bset cnt))
(setq bnfo (entget bnxt))
(if (= (cdr (assoc 0 bnfo)) "INSERT")
(progn
(setq bnfo (subst (cons 2 an) (assoc 41 bnfo) bnfo))
(entmod bnfo)
(entupd bnxt)
);progn
(princ "\nA Block was not Selected! ")
);if
(setq cnt (1+ cnt))
);end while
(command "REGENAUTO" "On")
(setvar "CMDECHO" 1)
(setvar "OSMODE" osm)
(prompt "\nBy Rob Herr robherr@hotmail.com")(print)
)