;-----------------------------------------------------------------------------------; ; ; ; DEMO.LSP by Michael Bulatovich February 26th, 2004 www.michaelbulatovich.ca ; ; ; ; Changes selected entities to an existing layer that shares the first two ; ; characters of the name of the entities current layer, followed ; ; by DEMO. ; ; ; ;-----------------------------------------------------------------------------------; (defun c:demo (/ target ss sslen entdata ent C elay nots froz flaglist) (setvar "cmdecho" 0) (setq ss (ssget) nots 0 C 0 froz 0 SSLEN (SSLENGTH SS) flaglist '(4 6) ) (WHILE (< C SSLEN) (SETQ ent (SSNAME SS c) entdata (ENTGET ent) elay (cdr (assoc 8 entdata)) target (strcat (substr elay 1 2) "demo") laydata (entget (tblobjname "layer" elay)) ) (if (not (eq nil (tblsearch "layer" target))) (if (member (cdr (assoc 70 laydata)) flaglist) (setq froz (+ 1 froz) c (+ 1 c) ) (progn (command "change" ent "" "p" "la" target "") (setq c (+ 1 c)) ) ) (setq c (+ 1 c) nots (+ 1 nots) ) ;end outer then ) ;end if ) ;end while (cond ((eq (- sslen nots froz) 1) (Princ "\nOne entity demolished.") ) ((> (- sslen nots froz) 1) (Princ (strcat "\n" (itoa (- sslen nots froz)) " entities demolished.") ) ) ) (cond ((eq froz 1) (Princ "\nOne entity not demolished because it's layer is locked." ) ) ((> froz 1) (Princ (strcat "\n" (itoa froz) " entities not demolished because their layers are locked." ) ) ) ) (cond ((eq nots 1) (Princ "\nOne entity not demolished because there is no existing demo layer for it." ) ) ((> nots 1) (Princ (strcat "\n" (itoa nots) " entities not demolished because there are no existing demo layers for them." ) ) ) ) (princ) )