;Redefines ALL objects in any block in the drawing on layer 0. ;(c)Jay Garnett (email jgarnett@enteract.com) Written 1/14/97 ;web page http://www.enteract.com/~jgarnett/lispfactory.htm ;Updated 1/25/97 - added select mode ; ;NUKE.LSP redefines all objects in a block on layer 0, with color and linetype ;set to BYLAYER. NUKED blocks will then take on the properties of the layer ;that they are inserted on. The routine works by modifing objects in the block table, ;so the blocks never have to be exploded. ; ;The global method redefines ALL objects in every block in the current drawing, ;except dimensions, hatching or xrefs, even if they are on a layer that is ;frozen or turned off. ; ;The select method redefines blocks selected with any standard selection method, ;as well as any blocks nested in the selected block(s). (defun To-0( BLCK / BNAME BLIST E EDATA SPIN TMP ) ;;; Prints a pinwheel on the command line (defun Spin ( ) (setq SYM (cond ((= SYM nil) "-") ((= SYM "-") "\\") ((= SYM "\\") "|") ((= SYM "|") "/") ((= SYM "/") "-") ) ) (princ (strcat "\rScanning... " SYM " ")) );end spin (if (=(type BLCK)(read "LIST"))(setq TMP(car BLCK) BLIST(cdr BLCK) BLCK TMP TMP nil)) (setq BLCK(tblsearch "BLOCK" BLCK)) (if (and (/=(logand(cdr(assoc 70 BLCK))1)1) ;skips annomyous blocks (/= (logand(cdr(assoc 70 BLCK))4)4) ;skips xrefs );and (progn (setq E (cdr (assoc -2 BLCK))) (while E (if (=(cdr(assoc 0 (entget E))) "INSERT") ;If the object is a block (progn (setq BNAME(cdr(assoc 2(entget E)))) ;save the name to a list (if (not (member BNAME BLIST)) (if (not BLIST)(setq BLIST (list BNAME)) ;create the list if it doesn't exist (setq BLIST(append BLIST(list BNAME))) );if );if );progn );if (setq EDATA (entget E)) (if (assoc 62 edata) (setq edata (subst (cons 62 0) (assoc 62 edata) edata)) (setq edata (append edata (list (cons 62 0)))) ) (if(assoc 6 EDATA) ;Resets object linetype to BYLAYER if it isn't. (setq EDATA(subst(cons 6 "BYLAYER")(assoc 6 EDATA)EDATA)) );if (setq EDATA(subst (cons 8 "0")(assoc 8 EDATA)EDATA));changes layer to 0 (entmod EDATA);updates entity (setq E (entnext E));get next enitiy, nil if end of block (Spin) );end while E );progn );if BLIST; returns names of any nested blocks );defun (defun C:xNUKE( / BLK_NM CHOICE E EDATA IDX PK_BLK SS) (command "._undo" "m") (setq CHOICE "S") (initget "G S") (setq CHOICE(getkword (strcat "\nlobal or elect block: <" CHOICE "> "))) (if(not CHOICE)(setq CHOICE "S")) (if (= (strcase CHOICE) "G") ;global nuke (while (setq BLK_NM(tblnext "BLOCK" (null BLK_NM))) (TO-0 (cdr(assoc 2 BLK_NM))) );while ;nuke selected block (progn (prompt "\nSelect Block(s) to Nuke: ") (setq SS(ssget '((0 . "INSERT")))) (setq IDX 0) (repeat (sslength SS) (setq BLK(cdr(assoc 2 (entget(ssname SS IDX))))) (cond (PK_BLK (setq PK_BLK(append PK_BLK (list BLK)))) (T (setq PK_BLK(list BLK))) );cond (setq IDX(1+ IDX)) );repeat (while PK_BLK (setq PK_BLK(To-0 PK_BLK)) );while );progn );if (command "._regen") (princ "\rFinished ") (princ) );defun (prompt"\nXNUKE zum Starten.")(princ)