Remove Layer Filters - How To

Discussion in 'AutoCAD' started by Dean McCarns, Dec 19, 2003.

  1. Dean McCarns

    Dean McCarns Guest

    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.
     
    Dean McCarns, Dec 19, 2003
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.