Unlike the previous post where you could only delete all but one attribute, this LISP routine allows you to delete all attributes in the selected blocks.
As seen below:
- ATTDEL2 <to start>
- Select blocks with attributes <enter> all attributes from these blocks will be deleted.
; written by Tony Burba ; found @ http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Need-lisp-to-delete-all-attributes-from-set-of-blocks/td-p/1565037 (defun tl_fld (v1 v2) (cdr (assoc v1 v2))) (defun c:attdel2 (/ ss cnt blk blkdat blknam blktblnam blknewdat blktbldat newblkdat atk_dbug nextent nextentdat nextenttyp endblklst ) (command "undo" "group") (setq atk_dbug nil) ;; (setq atk_dbug T) (if (setq ss (ssget (list (cons 0 "insert") (cons 66 1)))) (progn (setq cnt -1) (repeat (sslength ss) (setq blk (ssname ss (setq cnt (1+ cnt))) blkdat (entget blk) blknam (tl_fld 2 blkdat) newblknam (strcat blknam "_na") blknewdat (subst (cons 2 newblknam) (assoc 2 blkdat) blkdat ) blknewdat (subst (cons 66 0) (assoc 66 blknewdat) blknewdat ) ) (if (not (tblsearch "block" newblknam)) (progn (setq blktblnam (tblobjname "block" blknam) blktbldat (entget blktblnam) newblkdat (subst (cons 2 newblknam) (assoc 2 blktbldat) blktbldat ) newblkdat (subst (cons 70 (- (tl_fld 70 blktbldat) 2)) (assoc 70 blktbldat) newblkdat ) ) (if (entmake newblkdat) (progn (if atk_dbug (princ "\nStarting new block definition . . . ") ) (setq nextent (entnext blktblnam) nextentdat (entget nextent) nextenttyp (tl_fld 0 nextentdat) ) (while (and nextenttyp (/= nextenttyp "ENDBLK")) (if (/= nextenttyp "ATTDEF") (if (not (entmake nextentdat)) (princ "\nCan't make subentity.") (if atk_dbug (princ (strcat "\nAdding " nextenttyp " as subentity " (itoa xcnt) ) ) ) ) (if atk_dbug (princ "\nSkipping attribute definition.") ) ) (setq nextentdat nil nextenttyp nil ) (if (setq nextent (entnext nextent)) (setq nextentdat (entget nextent) nextenttyp (tl_fld 0 nextentdat) ) ) ) (setq endblklst (list (cons 0 "endblk") (cons 100 "AcDbBlockEnd") ) ) (if (not (entmake endblklst)) (princ "\nCan't terminate block definition") ) ) (princ "\nCan't start new block definition.") ) ) ) (if (tblsearch "block" newblknam) (progn (entdel blk) (entmake blknewdat) ) ) ) (setq ss nil) ) ) (command "undo" "end") (tl_$tlp) )
…. am I wrong when I think this is useless for AutoCAD LT?
kinda – You can create custom linetypes but you have to do them manually. LT can’t run AutoLISP.
However, a couple of years ago there was a 3rd party enabler that could let you run lisp files. I don’t know what ever happened to that.
Thank you very much. It works perfectly.
I’ve wasted a couple days on these disastrous xrefs. The attributes were the last thing I had to tackle. I could use ATTDISP to hide them in CAD, but linked into Revit they still show. Thanks for sharing it, you saved me a major headache.
I’m glad it helped
~Greg
Hi,
Thanks for the LISP. It kinda works but ATTSYNC restores the removed attributes. Is there are way to removed ALL attributes from the selected blocks for good?
Cheers,