Remove Layer Filters - How To

Dean McCarns

Usenet Archive
Joined
Jul 25, 2003
Messages
14
Reaction score
0
Good Evening Everyone;

I usually post on the ADT customization group but felt this little nugget would help all of you LISPers out there working with AutoCAD. I am working on a super purge program for ADT (that completely cleans the drawing and makes it r14 compatible for a client) and wanted to post this here for anyone who needs to get rid of those pesky layer filters that just keep popping up after a while.

This routine has been tested on 2002 only so no garuantees on 2004

(defun PurgeLayerFilters
(vl-load-com)
(esp:InitAc)
(if (and (= (vla-get-HasExtensionDictionary (vla-get-layers *AcDoc*)) :vlax-true) (= (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list (vla-getextensiondictionary (vla-get-layers *AcDoc*)) "ACAD_LAYERFILTERS") ) ) ) ) (vlax-for x (vla-item (vla-getextensiondictionary (vla-get-layers
*AcDoc*)) "ACAD_LAYERFILTERS")
(vla-delete x)
)
)
(esp:RelAc)
)

(defun c:PLF (PurgeLayerFilters))

The functions esp:InitAc and esp:RelAc are just a couple of automation routines to set the AutoCAD application, Document and Model Space as global variables (*AcApp*, *AcDoc* and *AcDocMs*) so you can substitute them as needed.

If you wish, you can replace the esp:InitAc with (setq AcDoc (vla-get-activedocument (vlax-get-acad-object))), replace all instances of
*AcDoc* with AcDoc and replace esp:RelAc with (vlax-release-object AcDoc)
and (setq AcDoc nil)

I added a command line access defun c:PLF so you can access this from the command line.

Hope this helps anyone who needs it and any comments are welcome.

P.S. Theres no error checking.
 

Latest threads

Back
Top