(defun c:blkswap (/ answr ent idx newname obj ss) ;from AUGI forums - http://forums.augi.com/showpost.php?p=354418&postcount=2 ;Thanks Miff ;modified to allow multiple selection (vl-load-com) ;;setup default on first run (if (not jmm-replaceall) (setq jmm-replaceall "Single") ) (command ".undo" "be") ;;if the user selects something, inputs a ne block name AND it exists in the dwg... ;(setq ss (ssget)) (if (and (setq ss (ssget '((0 . "INSERT")))) (progn (initget "Single Global") (if (setq answr (getkword "\nReplace just this block or Globally replace?[Single/Global]: ")) (setq jmm-replaceall answr) (setq answr jmm-replaceall) ) ) (setq newname (getstring "\nBlock name to replace with: ")) (tblobjname "BLOCK" newname) ) (progn (if (eq jmm-replaceall "Global");;get ALL occurances if it's Global, else use the original ss (setq ss (ssget "x" (list '(0 . "INSERT") (assoc 2 (entget (ssname ss 0)))))) ) (setq idx -1) (while (setq ent (ssname ss (setq idx (1+ idx)))) (setq obj (vlax-ename->vla-object ent)) (vla-put-name obj newname);;change the name (vla-update obj) ) ) ) (command ".undo" "end") (princ (strcat "\nReplaced " (itoa idx) " blocks......")) (princ) )