AutoLISP: Delete Invisible Attributes

Link to AutoCADtips

There are times when sending or submitting drawings to client or another drafter when the blocks in your drawings contain many attributes – some of which may be set to Invisible. And if you have ever wanted to delete invisible attributes, this routine is for you.

Warning: this does not work when trying to delete ALL attributes even if they are all set to invisible. At least one attribute has to be set to visible for this routine to work.

In case you are wondering how to set Attribute Visibility:

When creating an attribute you can toggle the visibility (as seen below)

Or when using the BATTMAN command you can edit which attributes are visible or invisible (seen below)

Another LISP routine [found here] allows you to select different instances of a block and toggle the visibility. Note: the DIA.lsp routine uses the command ATTSYNC which will synchronize all instances of a block based on the one you select.

Here’s how:

  • DIA <enter> to start
  • Type in the name of the block <enter>

that’s it

;;; By Lee-Mac
(defun delInvisAtts ( bname ) (vl-load-com)
(if (tblsearch "BLOCK" bname)
(vlax-for obj
(vla-get-activedocument (vlax-get-acad-object))
(if (and (eq (vla-get-objectname obj) "AcDbAttributeDefinition")
(eq (vla-get-invisible obj) :vlax-true)
(vla-delete obj)
(defun c:DIA ( / bn )
(delInvisAtts (setq bn (getstring t "\nBlock Name: ")))
(vl-cmdf "_.attsync" "_N" bn)

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in Attributes, AutoLISP, AutoLISP: Attributes, AutoLISP: Modify, Blocks, Modifying. Bookmark the permalink.

1 Response to AutoLISP: Delete Invisible Attributes

  1. Michael says:

    I know this is a very old post, but I wanted to let everyone know that the code posted by at The SWAMP by Lee Mac in reply #4 is different than the code posted above and, in my testing, it worked on all invisible attributes even when all the attributes in the block are invisible. I don’t know when it may have changed, or why it’s different, but it seems to work flawlessly.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s