;;;KETIV - Globally change the value of an attribute ;;; ;;; ATTREPLC.LSP ;;; ;;; KETIV Technologies, Inc. ;;; 6645 NE 78th Court #C2 ;;; Portland, OR 97218 ;;; ;;; Layer Group: NONE ;;; ;;; Menu Location: ;;; ;;; Purpose: To globally change the value of an attribute ;;; ;;; Prompts: Old attribute value: ;;; New attribute value: ;;; Case sensitive? : ;;; ;;; Assumptions/Limitations: NONE ;;; ;;;====================================================================================================== ;;; Initialize memory and important system variables ;;; ;;;> Author: Henry C. Francis ;;;> 425 N. Ashe St. ;;;> Southern Pines, NC 28387 ;;;> http://paracadd.com ;;;> All rights reserved. ;;; ;;;> COPYRIGHT: 1986, 1987, 1988, 1989 by KETIV Technologies, Inc. ;;;> EDITED: 04-08-1997 ;;; (defun c:attreplc (/ att block new newatt old oldatt params regen ss1 test typ value ) (setq clayer nil) ;================================================================================================== ; Prompt for the old and new attribute values (setq old (getstring t "\nOld attribute value: ")) (setq new (getstring t "\nNew attribute value: ")) (setq test (strcase (substr (getstring "\nCase sensitive? : ") 1 1))) (if (= test "N") (progn (setq old (strcase old)) (setq new (strcase new)) ) ) ; ;================================================================================================== ; Get all of the blocks that contain attributes (setq ss1 (ssget "X" '((66 . 1))) cnt 0) (if ss1 (setq block (ssname ss1 cnt))) (while block (setq att (entnext block)) (setq params (entget att)) (setq typ (cdr (assoc 0 params))) ; ;================================================================================================ ; As long as the found block has attributes left to search (while (and att (= typ "ATTRIB")) (setq oldatt (assoc 1 params)) (setq value (cdr oldatt)) (if (= test "N") (setq value (strcase value))) ; ;============================================================================================== ; Replace the attribute if the found value equals the decalared value to change (if (= value old) (progn (setq newatt (cons 1 new)) (setq params (subst newatt oldatt params)) (entmod params) (setq regen 1) ) ) (setq att (entnext att)) (setq params (entget att)) (setq typ (cdr (assoc 0 params))) ) (if regen (entupd block)) (setq cnt (1+ cnt) block (ssname ss1 cnt) regen nil) ) ; ;================================================================================================== ; Reset the atomlist (princ) ) (princ)