View Full Version : 2018 Save Layer Group Filters
arron.tucker720734
2017-06-07, 08:05 AM
Does anyone know of a way to save Layer Group filters?
We are using Uniclass 2015 and it would be nice to leave out the PR Table (over 5000 layers) until we need it.
Tom Beauford
2017-06-07, 11:06 AM
1. Check out AutoCAD commands LayerSaveFilterTree and LayerLoadFilterTree
2. Modify this LayFilterAdd.lsp:
; (load "LayFilterAdd.lsp")
; ^C^C^P(or LayFilterAdd (load "LayFilterAdd.lsp"));(LayFilterAdd)
; Save, close and reopen the DWT or DWG for the Filters to be put into alphabetical order.
(defun LayFilterAdd (/ collection names)
(setq names (list ""))
(if (not (vl-catch-all-error-p (setq collection (vl-catch-all-apply
(function (lambda () (vla-item (vla-getextensiondictionary (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) "ACAD_LAYERFILTERS")))
))))
; (vlax-for item collection (setq names (cons (strcase (vla-get-name item)) names))))
(vlax-for item collection (setq names (cons (vla-get-name item) names))))
names
(or(member "NODE" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*-NODE*\" or NAME== \"Layer*\"" "NODE" "X" nil))
(or(member "Sections" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"C-ROAD-SEC*\" or NAME== \"Layer*\"" "Sections" "X" nil))
(or(member "Profile" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"C-ROAD-PROF*\" or NAME== \"Layer*\"" "Profile" "X" nil))
(or(member "Topo" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"C-TOPO*\" or NAME== \"Layer*\"" "Topo" "X" nil))
(or(member "CALC Points" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"V-NODE-CALC\" or NAME== \"Layer*\"" "CALC Points" "X" nil))
(or(member "Only xrefs" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*|*\"" "Only xrefs" "X" nil))
(or(member "No xrefs" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"~*|*\"" "No xrefs" "X" nil))
(or(member "Linetype" names)(command "._-layer" "filter" "new" "property" "All" "LINETYPE==\"~Continuous\"" "Linetype" "X" nil))
(or(member "NCS" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"[A,C,E,L,V]-*\" or NAME== \"Layer*\"" "NCS" "X" nil))
(or(member "No NCS" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"~[A,C,E,L,V]-*\"" "No NCS" "X" nil))
; (or(member "No NCS" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"~@-*\"" "No NCS" "X" nil))
(or(member "No Civil" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"~[A,C,E,L,V]-*\"" "No Civil" "X" nil))
(princ "Layer Filter Names » ")(princ names)
(princ "\nSave, close and reopen the DWT or DWG for the Filters to be put into alphabetical order.")
(princ)
); function
(LayFilterAdd)
;| Lee Mac - http://www.cadtutor.net/forum/showthread.php?96276-Layer-property-filter-with-multiple-name-definitions&p=658278&viewfull=1#post658278
(command "_.-layer" "_filter" "_N" "_P" "" "NAME== \"20630*\" or NAME== \"Layer*\" or NAME== \"20632*\" or NAME== \"20633*\" or NAME== \"20634*\"" "206 - 01 - Group" "") |;
3. Check out this Export and import property layer filters routine by Gile: http://forums.augi.com/showthread.php?97438-Can-I-create-frequently-used-layer-filters-in-LISP&p=952247&viewfull=1#post952247
I have a drop-down in my Ribbon for Filters that includes this macro for selection a filter:
^C^C+Layer
Another custom macro example for when I use AutoTurn this macro adds a filter for it:
^C^C(command "-LAYER" "filter" "New" "Group" "All" "ATDIMS,ATTEXT,ATVEHICLE,AutoTURN,TSCONFLICT,TSINVISION,TSOBSTACLE,Veh-P" "AutoTurn" "eXit" "")
That should get you started.
arron.tucker720734
2017-06-07, 12:11 PM
Thanks for the reply.
1. Check out AutoCAD commands LayerSaveFilterTree and LayerLoadFilterTree
I believe these are only available in C3D and AutoCAD Architecture, not vanilla AutoCAD?
Tried them to no avail.
2. Modify this LayFilterAdd.lsp:
I used this to bring in the god knows how many Uniclass 2015 codes there are, BUT it won't put them into the Layer Groups set up.
The issue is currently it's impossible to save Layer Groups / import them.
Giles code works for layer property filters but not layer groups.
Tom Beauford
2017-06-07, 01:01 PM
Tip I got from Lee Mac in LayFilterAdd.lsp you should be able to use NAME==\"C-ROAD-SEC*\" or NAME== as in the first five filters in the lisp example to put all the layers in.
If you're still having trouble attach a blank drawing with the layers and the layer filter you need. I'll make it for you.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.