@drew_dewit wrote:
Hi,
I am looking for some LISP code to go through the drawing and delete all attribute definitions except for those defined in a list. The attributes are not contained in blocks but in the drawing itself.
Curios, why would you have ATTDEF's on your drawing? Obviously from exploded attributed blocks, why not take it one step further and convert the excluded ATTDEF into TEXT entity.
Building off @BeekeeCZ 's suggestion
(defun c:RemoveAttdefs (/ dxf_ lst ss i en ent data)
(setq dxf_ '(2 7 8 10 40 41)
lst '("TAG1"
"TAG2"
"TAG3"
)
)
(if (setq ss (ssget "_:L" '((0 . "ATTDEF"))))
(repeat (setq i (sslength ss))
(setq en (ssname ss (setq i (1- i)))
ent (entget en)
data (mapcar '(lambda (dx)
(Cdr (assoc dx ent))
)
dxf_
)
)
(if (vl-position (car data) lst)
(entmakex (append '((0 . "TEXT"))
(mapcar 'cons (Cons 1 (cdr dxf_)) data)
)
)
)
(entdel en)
)
)
(princ)
)
HTH