(defun c:ac ( / blk ent enx idx rtn sel tag val ) ;Lee Mac Programming
(while
(not
(or
(= "" (setq blk (strcase (getstring t "\nSpecify block name: "))))
(tblsearch "block" blk)
)
)
(princ (strcat "\nBlock " blk " not found."))
)
(if (and (/= "" blk) (setq tag (strcase (getstring "\nSpecify attribute tag: "))))
(progn
(setq val (strcase (getstring t "\nSpecify attribute value: "))
rtn 0
)
(if
(and
(setq sel
(ssget "_X"
(list
'(00 . "INSERT")
'(66 . 1)
(cons 02 (strcat "`*U*," blk))
(if (= 1 (getvar 'cvport))
(cons 410 (getvar 'ctab))
'(410 . "Model")
)
)
)
)
(progn
(repeat (setq idx (sslength sel))
(setq ent (ssname sel (setq idx (1- idx))))
(if (= blk (strcase (LM:name->effectivename (cdr (assoc 2 (entget ent))))))
(progn
(setq ent (entnext ent)
enx (entget ent)
)
(while
(and (= "ATTRIB" (cdr (assoc 0 enx)))
(not
(and
(= tag (strcase (cdr (assoc 2 enx))))
(= val (strcase (cdr (assoc 1 enx))))
(setq rtn (1+ rtn))
)
)
)
(setq ent (entnext ent)
enx (entget ent)
)
)
)
)
)
( Effective Block Name - Lee Mac
;; blk - [str] Block name

(defun LM:name->effectivename ( blk / rep )
(if
(and (wcmatch blk "`**")
(setq rep
(cdadr
(assoc -3
(entget
(cdr (assoc 330 (entget (tblobjname "block" blk))))
'("AcDbBlockRepBTag")
)
)
)
)
(setq rep (handent (cdr (assoc 1005 rep))))
)
(cdr (assoc 2 (entget rep)))
blk
)
)

(princ)
(c:ac)

Advertisements