;Update or Replace an existing block. (uses USTR UKWORD) (defun c:rblk ( / ) (setq lupr (getvar"luprec")) (setq attrq (getvar"attreq")) (setvar "ATTREQ" 0) ;(princ "\n MODIFIED FOR SINGLE USE - UNMODIFY TO RESTORE ") (if roru (setq ent (entget(car(entsel "Select block to update: "))) blknm (cdr(assoc 2 ent))) ; (setq ent (entget(ssname(ssget "x" '((-4 . "")))0)) ; blknm "POMTTBAT") (setq ent (entget(car(entsel "Select block to replace: "))) blknm (ustr 1 (strcat"Block name to replace "(cdr(assoc 2 ent))" with")blknm nil)) );if (setq r_mode (ukword 1 "One Many All" "Replace Block Mode (One, Many or All)" r_mode)) ;(setq r_mode "One") (princ (cons 2 (strcat "\`" (cdr (assoc 2 ent))))) (cond ((eq r_mode "All") (setq getit (list (cons -4 "") )) (setq tset (ssget "x" getit)) ) ((eq r_mode "One") (if (eq (substr (cdr (assoc 2 ent)) 1 1) "*") (setq tset (ssget "x" (list (assoc 0 ent)(assoc 8 ent)(cons 2 (strcat "\`" (cdr (assoc 2 ent))))(assoc 10 ent)))) (setq tset (ssget "x" (list (assoc 0 ent)(assoc 8 ent)(assoc 2 ent)(assoc 10 ent)))) ) ) ((eq r_mode "Many") (setq tset (ssget getit)) ) ) (if tset (progn (setq tsln (sslength tset)) (setq cntr 0) ) ) (command ".insert" (strcat blknm "=")) (command) (if c:svlayr (c:svlayr) (progn (load "mklayr") (c:svlayr) ) ) ;(if clnmstd nil (load"mklayr")) ;(if(clnmstd) ; (if(not(=(substr clayr 2 1)"-")) ; (setq llt "-") ; );if ;);if ;(setq modf "SYMB") ;(c:mklayr) (while (if (and (< cntr tsln) tset) (setq tent (entget (ssname tset cntr))) );if (progn (setq edtw (entget (cdar tent)) xent (ssname tset cntr) inxyz (strcat(rtos(cadr(assoc 10 edtw))2 8)","(rtos(caddr(assoc 10 edtw))2 8)) xscl (cdr(assoc 41 edtw)) yscl (cdr(assoc 42 edtw)) zscl (cdr(assoc 43 edtw)) elay (cdr(assoc 8 edtw)) inang (angtos(cdr(assoc 50 edtw))(getvar"aunits")8) );SETQ (setvar "clayer" elay) (command ".insert" blknm inxyz xscl yscl inang) (setq tent (entlast)) (setq bins (entlast)) );progn (while (and (setq attr (entnext xent)) (not(eq(cdr(assoc 0 (entget attr)))"SEQEND")) (not(eq(cdr(assoc 0 (entget attr)))"INSERT")) );and (if(eq(cdr(assoc 0(entget attr)))"ATTRIB") (set (read(cdr(assoc 2(entget attr))))(assoc 1(entget attr))) );if (setq xent (entnext xent)) );while (while (and (setq attr (entnext bins)) (not(eq(cdr(assoc 0 (entget attr)))"SEQEND")) (not(eq(cdr(assoc 0 (entget attr)))"INSERT")) );and (setq bins (entnext bins)) (setq edtw (entget attr)) (cond ((and (eq(cdr(assoc 2 edtw))"SEC/DET_REF") (eq(cdr(assoc 0 edtw))"ATTRIB") att1 att2 att3 );and (progn (setq edtw (subst att1 (assoc 1 edtw) edtw );subst );setq (entmod edtw) (entmod (entget tent)) ));and & progn ((and (eq(cdr(assoc 2 edtw))"SHT_CALL_ON") (eq(cdr(assoc 0 edtw))"ATTRIB") att1 att2 att3 );and (progn (setq edtw (subst att2 (assoc 1 edtw) edtw );subst );setq (entmod edtw) (entmod (entget tent)) ));and & progn ((and (eq(cdr(assoc 2 edtw))"SHT_DRWN_ON") (eq(cdr(assoc 0 edtw))"ATTRIB") att1 att2 att3 );and (progn (setq edtw (subst att3 (assoc 1 edtw) edtw );subst );setq (entmod edtw) (entmod (entget tent)) ));and & progn );cond );while (setq cntr (1+ cntr)) (entdel (cdar edtw)) );while (setvar "LUPREC" lupr) (setvar "ATTREQ" attrq) (c:rslayr) (princ) ;(command ".resume") );DEFUN