;; Select Blocks by Attribute Value - Lee Mac ;; Selects all attributed blocks in the current layout which contain a specified attribute value. (defun c:selblkbyattval ( / att atx ent idx sel str ) (if (/= "" (setq str (strcase (getstring t "\nSpecify attribute value: ")))) (if (and (setq sel (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model") ) ) ) ) (progn (repeat (setq idx (sslength sel)) (setq ent (ssname sel (setq idx (1- idx))) att (entnext ent) atx (entget att) ) (while (and (= "ATTRIB" (cdr (assoc 0 atx))) (not (wcmatch (strcase (cdr (assoc 1 atx))) str)) ) (setq att (entnext att) atx (entget att) ) ) (if (= "SEQEND" (cdr (assoc 0 atx))) (ssdel ent sel) ) ) (< 0 (sslength sel)) ) ) (sssetfirst nil sel) (princ (strcat "\nNo blocks found with attribute value matching \"" str "\".")) ) ) (princ) )