|
Welcome, Guest.
|
||||||
| AutoLISP AutoLISP or Visual LISP, learn both here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Woo! Hoo! my 1st post
Join Date: 2003-12
Posts: 1
![]() |
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. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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
|
|
|
|
|
|
#3 |
|
I could stop if I wanted to
Join Date: 2003-09
Posts: 298
![]() |
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
Regards, Vince Last edited by Opie : 2008-10-11 at 07:11 PM. Reason: [code] tags added |
|
|
|
|
|
#4 |
|
Administrator
Join Date: 2001-08
Location: Seattle WA US
Posts: 4,393
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Vince,
Your version of my code is out of date. Please see my post in this thread for a new version. |
|
|
|
|
|
#5 |
|
Member
Join Date: 2004-07
Posts: 15
![]() |
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.
|
|
|
|
|
|
#6 | |
|
Active Member
Join Date: 2003-05
Location: Iowa
Posts: 60
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
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. |
|
|
|
|
|
|
#7 |
|
AUGI Addict
Join Date: 2002-04
Location: Colorado
Posts: 1,647
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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. |
|
|
|
|
|
#8 |
|
Member
Join Date: 2004-09
Posts: 3
![]() |
This routing rocks!. Thank you all.
|
|
|
|
|
|
#9 | |
|
Active Member
Join Date: 2004-11
Location: All of the Midwest
Posts: 53
![]() ![]() ![]() ![]() |
Quote:
thanks in advance -jde |
|
|
|
|
|
|
#10 |
|
Active Member
Join Date: 2003-05
Location: Iowa
Posts: 60
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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. |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
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 |