Saturday, November 21, 2009
Home   |   Search   |   About AUGI   |   My AUGI   |   Join Now

Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP
 Welcome, Guest. 

Login

Join Now FAQ Members List Calendar Search Today's Posts Mark Forums Read

AutoLISP AutoLISP or Visual LISP, learn both here!

Reply
 
Thread Tools Display Modes
Old 2004-06-07, 11:02 PM   #1
rabitsarchitects
Woo! Hoo! my 1st post
 
Join Date: 2003-12
Posts: 1
rabitsarchitects is starting their journey
Default Need Help Deleting "Named Layer Filters"

Does anybody have a LISP routine or anything else that I could use to delete "Named Layer Filters ??

I'm finding drawings with Hundreds maybe Thousands of Named Layer Filters. They are all useless. They are just junk brought over from previous drawings. I deleted the Layer filters from one drawing and it dropped the file size by over 500k. If I can find something to run on all our drawings this would free up an enormous amount of space...\

Thanks for any help you can give...

Rob G.
rabitsarchitects is offline   Reply With Quote
Old 2004-06-08, 12:13 AM   #2
RobertB
Administrator
 
RobertB's Avatar
 
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
RobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the stars
Default RE: Need Help Deleting "Named Layer Filters"

I have posted this code in several places; I guess I should here also!

Code:
;|

Written by: 	R. Robert Bell
Purpose:	Allows the user to enter a wildcard string to keep any matching filters.
Sample string:	"`#*,MW*" will keep all filters beginning with a "#" or "MW"

Copyright © 2004 by R. Robert Bell

|;

(defun rrbI:LayerFiltersDelete  (strKeepWC / objXDict)
 ;; This function insures that an Extension Dictionary exists, and works on both locations for layer filters
 (vl-load-com)                                                                  ; load ActiveX if needed
 (vl-catch-all-apply                                                            ; trap error if no extension dictionary
  (function
   (lambda ()
    (setq objXDict (vla-GetExtensionDictionary                                  ; bind dictionary to variable
                    (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))))))))
 (cond (objXDict                                                                ; if the extension dictionary exists
        (or                                                                     ; use OR to return T for success
         (rrbI:DeleteAllXRecs objXDict "ACAD_LAYERFILTERS" strKeepWC)           ; pre-2005 layer filters
         (rrbI:DeleteAllXRecs objXDict "AcLyDictionary" strKeepWC)))))          ; 2005 layer filters

(defun rrbI:DeleteAllXRecs  (objXDict dictName strKeepWC / objDict i)
 ;; This function performs the chore of deleting each filer that doesn't match the wildcard
 (vl-catch-all-apply                                                            ; trap errors
  (function
   (lambda ()
    (setq objDict (vla-Item objXDict dictName))                                 ; get layer filters dictionary
    (vlax-for objXRec  objDict                                                  ; loop thru all XRecords in the dictionary
     (cond ((not (and strKeepWC (wcmatch (vla-Get-Name objXRec) strKeepWC)))    ; if deleting all filters, or current doesn't match wildcard
            (setq i (1+ (cond (i)                                               ; increment counter
                              (0))))                                            ; initialize counter
            (vla-Delete objXRec)))))))                                          ; delete filter
 (cond (i (princ (strcat "\n" (itoa i) " filters deleted.")))))                 ; if counter is bound, report number of filters deleted

(defun C:LFD  (/ inpKeep)
 ;; Main command-line function
 (setq inpKeep (getstring
                "\nWildcard mask for filters to keep, or <Enter> to delete all: "))
 (rrbI:LayerFiltersDelete (cond ((/= inpKeep "") inpKeep)))                     ; pass nil to subr if user hit <Enter>
 (princ))                                                                       ; clean exit
RobertB is offline   Reply With Quote
Old 2004-06-18, 07:25 PM   #3
vferrara
I could stop if I wanted to
 
Join Date: 2003-09
Posts: 298
vferrara appears to be going the right way
Default RE: Need Help Deleting &quot;Named Layer Filters&quot;

Rob:

I have used this code to delete all of the layer filters on our drawings. It works well and is very fast.

Code:
;;;;;;Start Of Code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;
;;;;;;DELETE LAYER FILTERS
;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:LFD  ()
 (vl-Load-Com)
 (vl-Catch-All-Apply
  '(lambda ()
    (vla-Remove (vla-GetExtensionDictionary
                 (vla-Get-Layers 
                  (vla-Get-ActiveDocument
                   (vlax-Get-Acad-Object))))
                "ACAD_LAYERFILTERS")))

 (princ "\n...")
 (princ "\n...All Layer Filters Have Been Deleted...")
 (princ)

)
;;;;;;End Of Code
I hope you can find this helpful.

Regards,
Vince

Last edited by Opie : 2008-10-11 at 07:11 PM. Reason: [code] tags added
vferrara is offline   Reply With Quote
Old 2004-06-19, 08:47 PM   #4
RobertB
Administrator
 
RobertB's Avatar
 
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
RobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the starsRobertB is shooting for the stars
Default

Vince,

Your version of my code is out of date. Please see my post in this thread for a new version.
RobertB is offline   Reply With Quote
Old 2004-09-23, 05:55 PM   #5
jetman
Member
 
Join Date: 2004-07
Posts: 15
jetman is starting their journey
Red face RE: Need Help Deleting &quot;Named Layer Filters&quot;

Free download of CDG Purge developed by the CAD Development Group, LLP will allow you to purge a number of different things from your drawings, including any unused layer filters. Check it out. I use it all the time, so much that I made a tool button for it.
jetman is offline   Reply With Quote
Old 2004-09-28, 06:15 PM   #6
jkramer
Active Member
 
jkramer's Avatar
 
Join Date: 2003-05
Location: Iowa
Posts: 60
jkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightly
Default RE: Need Help Deleting &quot;Named Layer Filters&quot;

Quote:
Originally Posted by RobertB
Vince,

Your version of my code is out of date. Please see my post in this thread for a new version.
Robert,

I have tried using yours and Vince's code and yours gives me some problems (but Vince's works). It asks a question that requires an "<enter> to delete all" and then I have to regen my drawing to get the layer filters to actually go away. (The layerfiltersdelete is an unknown command, so the only way it works is with LFD.)

What is out of date about Vince's, and why is yours not working for me?

Thank you,
Jessica
__________________
Duct tape is like the force, it has a lite side, a dark side, and it holds the Universe togther.

Last edited by jkramer : 2004-09-28 at 06:18 PM.
jkramer is offline   Reply With Quote
Old 2004-11-09, 12:16 AM   #7
jpaulsen
AUGI Addict
 
jpaulsen's Avatar
 
Join Date: 2002-04
Location: Colorado
Posts: 1,647
jpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the starsjpaulsen is shooting for the stars
Default RE: Need Help Deleting &quot;Named Layer Filters&quot;

I did some experimenting with both routines and this is what I found. I tried them in the 2002 versions of LDT / Map with SP1 and LDT / Map 2005 SP1.

The long version works great in 2005 and with limited testing in 2002 it seems to work fine there too.

The short routine will not delete layer filters created in 2005 or layer filters created in 2002 that are recognized by 2005. In other words, if they show up in the layer filter list in 2005 the short version would not delete them.

However, there is still a use for the short version in 2005. I found that in some drawings the layer drop-down list on the Layer toolbar is very slow. Running the short version fixes this problem. For more info on the slow drop-down see this thread.

P.S. I forgot to mention two other things about the long routine. The wild card functionality is case sensitive. Also the routine does not appear to delete any layer filters if one or more were created in that drawing session.
__________________
Jeff Paulsen
CAD Manager

Last edited by jpaulsen : 2004-11-09 at 02:24 PM.
jpaulsen is offline   Reply With Quote
Old 2004-12-17, 07:00 PM   #8
roy.75262
Member
 
Join Date: 2004-09
Posts: 3
roy.75262 is starting their journey
Default RE: Need Help Deleting &quot;Named Layer Filters&quot;

This routing rocks!. Thank you all.
roy.75262 is offline   Reply With Quote
Old 2005-01-18, 12:43 AM   #9
justin.d.ehart
Active Member
 
justin.d.ehart's Avatar
 
Join Date: 2004-11
Location: All of the Midwest
Posts: 53
justin.d.ehart is going the right wayjustin.d.ehart is going the right wayjustin.d.ehart is going the right wayjustin.d.ehart is going the right way
Default RE: Need Help Deleting &quot;Named Layer Filters&quot;

Quote:
Originally Posted by RobertB
I have posted this code in several places; I guess I should here also!

Code:
;|

Written by: 	R. Robert Bell
Purpose:	Allows the user to enter a wildcard string to keep any matching filters.
Sample string:	"`#*,MW*" will keep all filters beginning with a "#" or "MW"

Copyright © 2004 by R. Robert Bell

|;

(defun rrbI:LayerFiltersDelete  (strKeepWC / objXDict)
 ;; This function insures that an Extension Dictionary exists, and works on both locations for layer filters
 (vl-load-com)                                                                  ; load ActiveX if needed
 (vl-catch-all-apply                                                            ; trap error if no extension dictionary
  (function
   (lambda ()
    (setq objXDict (vla-GetExtensionDictionary                                  ; bind dictionary to variable
                    (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))))))))
 (cond (objXDict                                                                ; if the extension dictionary exists
        (or                                                                     ; use OR to return T for success
         (rrbI:DeleteAllXRecs objXDict "ACAD_LAYERFILTERS" strKeepWC)           ; pre-2005 layer filters
         (rrbI:DeleteAllXRecs objXDict "AcLyDictionary" strKeepWC)))))          ; 2005 layer filters

(defun rrbI:DeleteAllXRecs  (objXDict dictName strKeepWC / objDict i)
 ;; This function performs the chore of deleting each filer that doesn't match the wildcard
 (vl-catch-all-apply                                                            ; trap errors
  (function
   (lambda ()
    (setq objDict (vla-Item objXDict dictName))                                 ; get layer filters dictionary
    (vlax-for objXRec  objDict                                                  ; loop thru all XRecords in the dictionary
     (cond ((not (and strKeepWC (wcmatch (vla-Get-Name objXRec) strKeepWC)))    ; if deleting all filters, or current doesn't match wildcard
            (setq i (1+ (cond (i)                                               ; increment counter
                              (0))))                                            ; initialize counter
            (vla-Delete objXRec)))))))                                          ; delete filter
 (cond (i (princ (strcat "\n" (itoa i) " filters deleted.")))))                 ; if counter is bound, report number of filters deleted

(defun C:LFD  (/ inpKeep)
 ;; Main command-line function
 (setq inpKeep (getstring
                "\nWildcard mask for filters to keep, or <Enter> to delete all: "))
 (rrbI:LayerFiltersDelete (cond ((/= inpKeep "") inpKeep)))                     ; pass nil to subr if user hit <Enter>
 (princ))                                                                       ; clean exit
So where do I copy and paste this code to run it? In the MNU file? I am sorry I am new to this particular routine!

thanks in advance
-jde
justin.d.ehart is offline   Reply With Quote
Old 2005-01-18, 02:00 PM   #10
jkramer
Active Member
 
jkramer's Avatar
 
Join Date: 2003-05
Location: Iowa
Posts: 60
jkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightlyjkramer is glowing brightly
Default

You will want to make this a .lsp file and you will need to go into appload to load it up. "LayerFiltersDelete" without the quotes, is what you would type on the command line to make it work.

Good luck, it works like a charm!
__________________
Duct tape is like the force, it has a lite side, a dark side, and it holds the Universe togther.
jkramer is offline   Reply With Quote
Reply


Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mechanical Structure vs. Layer Groups - Your Input chill AutoCAD Mechanical - General 12 2007-06-18 05:30 PM
ActiveX API - Layer Filter Manipulation ntaylor API Wish List 6 2004-09-09 12:58 AM
Grid Head / Grid lines on separate export layer Griff Revit Architecture - General 1 2004-02-10 11:02 PM


All times are GMT +1. The time now is 01:13 PM.