; -----------------------------------------; ; ; ; BYL.LSP by Michael Bulatovich ; ; www.michaelbulatovich.ca ; ; ; ; Changes current color and linetype ; ; or selected entities to BYLAYER ; ; color and linetype. Michael Bulatovich; ; ; ; -----------------------------------------; (Defun C:byl (/ SS CNT cntr ent entd sslen) ;(init_bonus_error ; (list ; (list "cmdecho" 0) ; T ;flag. True means use undo for error clean up. ; );list ;);init_bonus_error (if (not (setq SS (ssget "i"))) (progn (prompt "\nPress Enter to change current settings to BYLAYER,\nOR to change object properties to BYLAYER....") (setq SS (ssget)) ) ) (if SS (progn (setq CNT (sslength SS)) (princ (strcat "\n" (itoa CNT) " found.")) ; Report number of items found (command "_.move" SS "") ; filter out objects on locked layers (if (> (getvar "cmdactive") 0) ; if there are still objects left (progn (command "0,0" "0,0") (setq SS (ssget "p") sslen (sslength ss) CNT (- CNT sslen) ; count them ) ) (setq SS nil) ; else abort operation ) (if (> CNT 0) ; if items where filtered out (if (= CNT 1) (princ (strcat "\n" (itoa CNT) " was on a locked layer.")) ; report it. (princ (strcat "\n" (itoa CNT) " were on a locked layer.")) ) ) ) (progn (setvar "cecolor" "bylayer") ;if no items are selected change system variables to bylayer (setvar "celtype" "bylayer") ) ) (if SS ;loop throught the set, changing color and linetype to bylayer (progn (Setq cntr 0) (while (< cntr sslen) (setq ent (ssname ss cntr)) (setq entd (entget ent)) (setq entd (subst (cons 6 "bylayer") (assoc 6 entd) entd )) (setq entd (subst (cons 62 256) (assoc 62 entd) entd)) (entmod entd) (setq cntr (1+ cntr)))) (progn (setvar "cecolor" "bylayer") ;or, if no items are selected, change system variables to bylayer (setvar "celtype" "bylayer") )) (princ) )