Jump to content
ktbjx

AutoLisp to group filter layers????

Recommended Posts

ktbjx

I have this layers,

1g0q52.jpg

 

I know how to make a new layer from Autolisp, but I don't know how to make a group filter from the layers made.

Also as you can see in the image, the layers have strings("CONTOUR_EL") attached to elevations, so i cannot just use If statements to it.

Can someone help me group filter all the layers please?

 

here is the ranges:

1170 - 1238 = "1150 LEVEL"
1110 - 1168 = "1100 LEVEL"
1070 - 1108 = "1070 LEVEL"
1020 - 1068 = "1000 LEVEL"
962 - 1018 = "950 LEVEL"
910 - 960 = "900 LEVEL"
870 - 908 = "850 LEVEL"
810 - 868 = "800 LEVEL"
770 - 808 = "750 LEVEL"
710 - 778 = "700 LEVEL"
670 - 708 = "670 LEVEL"

 

help? or at least show me how to make it, and ill try to make one myself

  • Like 1

Share this post


Link to post
Share on other sites
tombu

Here's how I load mine:

; (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 (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 "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))
  (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)

wcmatch (AutoLISP) https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-AutoLISP/files/GUID-EC257AF7-72D4-4B38-99B6-9B09952A53AD-htm.html

 

Share this post


Link to post
Share on other sites
tombu

Gotta wonder how you managed to have seperate layers for every contour elevation?

I'd be looking for a lisp to merge layers CONTOUR_EL "1170 thru 1238" into "1150 LEVEL" and so on.

Contour_Index and Contour_Intermediate would be all the layers I'd use.

Share this post


Link to post
Share on other sites
BIGAL

We have never really had the need for anything but Major and Minor contour layers ie 2 layers. The only time I have played with multi layers was to do with water volumes in ponds.

Share this post


Link to post
Share on other sites
ktbjx
Posted (edited)
On 3/7/2019 at 9:13 PM, tombu said:

Here's how I load mine:


; (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 (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 "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))
  (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)

wcmatch (AutoLISP) https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-AutoLISP/files/GUID-EC257AF7-72D4-4B38-99B6-9B09952A53AD-htm.html

 

 

 

Sir Thank you so much for your routine...

I edit it for my Filter and it works!

Its long, i know, but its easy! i used excel and mostly concatenation and COPY>TRANSPOSE...

 

Heres what i came up with:

 

(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 (vla-get-name item) names))))
names
(or(member "670 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL670*\" or NAME==\"*CONTOUR_EL672*\" or NAME==\"*CONTOUR_EL674*\" or NAME==\"*CONTOUR_EL676*\" or NAME==\"*CONTOUR_EL678*\" or NAME==\"*CONTOUR_EL680*\" or NAME==\"*CONTOUR_EL682*\" or NAME==\"*CONTOUR_EL684*\" or NAME==\"*CONTOUR_EL686*\" or NAME==\"*CONTOUR_EL688*\" or NAME==\"*CONTOUR_EL690*\" or NAME==\"*CONTOUR_EL692*\" or NAME==\"*CONTOUR_EL694*\" or NAME==\"*CONTOUR_EL696*\" or NAME==\"*CONTOUR_EL698*\" or NAME==\"*CONTOUR_EL700*\" or NAME==\"*CONTOUR_EL702*\" or NAME==\"*CONTOUR_EL704*\" or NAME==\"*CONTOUR_EL706*\"" "670 LEVEL" "X" nil))

(or(member "700 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL710*\" or NAME==\"*CONTOUR_EL712*\" or NAME==\"*CONTOUR_EL714*\" or NAME==\"*CONTOUR_EL716*\" or NAME==\"*CONTOUR_EL718*\" or NAME==\"*CONTOUR_EL720*\" or NAME==\"*CONTOUR_EL722*\" or NAME==\"*CONTOUR_EL724*\" or NAME==\"*CONTOUR_EL726*\" or NAME==\"*CONTOUR_EL728*\" or NAME==\"*CONTOUR_EL730*\" or NAME==\"*CONTOUR_EL732*\" or NAME==\"*CONTOUR_EL734*\" or NAME==\"*CONTOUR_EL736*\" or NAME==\"*CONTOUR_EL738*\" or NAME==\"*CONTOUR_EL740*\" or NAME==\"*CONTOUR_EL742*\" or NAME==\"*CONTOUR_EL744*\" or NAME==\"*CONTOUR_EL746*\" or NAME==\"*CONTOUR_EL748*\" or NAME==\"*CONTOUR_EL750*\" or NAME==\"*CONTOUR_EL752*\" or NAME==\"*CONTOUR_EL754*\" or NAME==\"*CONTOUR_EL756*\" or NAME==\"*CONTOUR_EL758*\" or NAME==\"*CONTOUR_EL760*\" or NAME==\"*CONTOUR_EL762*\" or NAME==\"*CONTOUR_EL764*\" or NAME==\"*CONTOUR_EL766*\" or NAME==\"*CONTOUR_EL768*\"" "700 LEVEL" "X" nil))

(or(member "750 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL770*\" or NAME==\"*CONTOUR_EL772*\" or NAME==\"*CONTOUR_EL774*\" or NAME==\"*CONTOUR_EL776*\" or NAME==\"*CONTOUR_EL778*\" or NAME==\"*CONTOUR_EL780*\" or NAME==\"*CONTOUR_EL782*\" or NAME==\"*CONTOUR_EL784*\" or NAME==\"*CONTOUR_EL786*\" or NAME==\"*CONTOUR_EL788*\" or NAME==\"*CONTOUR_EL790*\" or NAME==\"*CONTOUR_EL792*\" or NAME==\"*CONTOUR_EL794*\" or NAME==\"*CONTOUR_EL796*\" or NAME==\"*CONTOUR_EL798*\" or NAME==\"*CONTOUR_EL800*\" or NAME==\"*CONTOUR_EL802*\" or NAME==\"*CONTOUR_EL804*\" or NAME==\"*CONTOUR_EL806*\" or NAME==\"*CONTOUR_EL808*\"" "750 LEVEL" "X" nil))

(or(member "800 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL810*\" or NAME==\"*CONTOUR_EL812*\" or NAME==\"*CONTOUR_EL814*\" or NAME==\"*CONTOUR_EL816*\" or NAME==\"*CONTOUR_EL818*\" or NAME==\"*CONTOUR_EL820*\" or NAME==\"*CONTOUR_EL822*\" or NAME==\"*CONTOUR_EL824*\" or NAME==\"*CONTOUR_EL826*\" or NAME==\"*CONTOUR_EL828*\" or NAME==\"*CONTOUR_EL830*\" or NAME==\"*CONTOUR_EL832*\" or NAME==\"*CONTOUR_EL834*\" or NAME==\"*CONTOUR_EL836*\" or NAME==\"*CONTOUR_EL838*\" or NAME==\"*CONTOUR_EL840*\" or NAME==\"*CONTOUR_EL842*\" or NAME==\"*CONTOUR_EL844*\" or NAME==\"*CONTOUR_EL846*\" or NAME==\"*CONTOUR_EL848*\" or NAME==\"*CONTOUR_EL850*\" or NAME==\"*CONTOUR_EL852*\" or NAME==\"*CONTOUR_EL854*\" or NAME==\"*CONTOUR_EL856*\" or NAME==\"*CONTOUR_EL858*\" or NAME==\"*CONTOUR_EL860*\" or NAME==\"*CONTOUR_EL862*\" or NAME==\"*CONTOUR_EL864*\" or NAME==\"*CONTOUR_EL866*\" or NAME==\"*CONTOUR_EL868*\"" "800 LEVEL" "X" nil))

(or(member "850 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL870*\" or NAME==\"*CONTOUR_EL872*\" or NAME==\"*CONTOUR_EL874*\" or NAME==\"*CONTOUR_EL876*\" or NAME==\"*CONTOUR_EL878*\" or NAME==\"*CONTOUR_EL880*\" or NAME==\"*CONTOUR_EL882*\" or NAME==\"*CONTOUR_EL884*\" or NAME==\"*CONTOUR_EL886*\" or NAME==\"*CONTOUR_EL888*\" or NAME==\"*CONTOUR_EL890*\" or NAME==\"*CONTOUR_EL892*\" or NAME==\"*CONTOUR_EL894*\" or NAME==\"*CONTOUR_EL896*\" or NAME==\"*CONTOUR_EL898*\" or NAME==\"*CONTOUR_EL900*\" or NAME==\"*CONTOUR_EL902*\" or NAME==\"*CONTOUR_EL904*\" or NAME==\"*CONTOUR_EL906*\" or NAME==\"*CONTOUR_EL908*\"" "850 LEVEL" "X" nil))

(or(member "900 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL910*\" or NAME==\"*CONTOUR_EL912*\" or NAME==\"*CONTOUR_EL914*\" or NAME==\"*CONTOUR_EL916*\" or NAME==\"*CONTOUR_EL918*\" or NAME==\"*CONTOUR_EL920*\" or NAME==\"*CONTOUR_EL922*\" or NAME==\"*CONTOUR_EL924*\" or NAME==\"*CONTOUR_EL926*\" or NAME==\"*CONTOUR_EL928*\" or NAME==\"*CONTOUR_EL930*\" or NAME==\"*CONTOUR_EL932*\" or NAME==\"*CONTOUR_EL934*\" or NAME==\"*CONTOUR_EL936*\" or NAME==\"*CONTOUR_EL938*\" or NAME==\"*CONTOUR_EL940*\" or NAME==\"*CONTOUR_EL942*\" or NAME==\"*CONTOUR_EL944*\" or NAME==\"*CONTOUR_EL946*\" or NAME==\"*CONTOUR_EL948*\" or NAME==\"*CONTOUR_EL950*\" or NAME==\"*CONTOUR_EL952*\" or NAME==\"*CONTOUR_EL954*\" or NAME==\"*CONTOUR_EL956*\" or NAME==\"*CONTOUR_EL958*\" or NAME==\"*CONTOUR_EL960*\"" "900 LEVEL" "X" nil))

(or(member "950 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL962*\" or NAME==\"*CONTOUR_EL964*\" or NAME==\"*CONTOUR_EL966*\" or NAME==\"*CONTOUR_EL968*\" or NAME==\"*CONTOUR_EL970*\" or NAME==\"*CONTOUR_EL972*\" or NAME==\"*CONTOUR_EL974*\" or NAME==\"*CONTOUR_EL976*\" or NAME==\"*CONTOUR_EL978*\" or NAME==\"*CONTOUR_EL980*\" or NAME==\"*CONTOUR_EL982*\" or NAME==\"*CONTOUR_EL984*\" or NAME==\"*CONTOUR_EL986*\" or NAME==\"*CONTOUR_EL988*\" or NAME==\"*CONTOUR_EL990*\" or NAME==\"*CONTOUR_EL992*\" or NAME==\"*CONTOUR_EL994*\" or NAME==\"*CONTOUR_EL996*\" or NAME==\"*CONTOUR_EL998*\" or NAME==\"*CONTOUR_EL1000*\" or NAME==\"*CONTOUR_EL1002*\" or NAME==\"*CONTOUR_EL1004*\" or NAME==\"*CONTOUR_EL1006*\" or NAME==\"*CONTOUR_EL1008*\" or NAME==\"*CONTOUR_EL1010*\" or NAME==\"*CONTOUR_EL1012*\" or NAME==\"*CONTOUR_EL1014*\" or NAME==\"*CONTOUR_EL1016*\" or NAME==\"*CONTOUR_EL1018*\"" "950 LEVEL" "X" nil))

(or(member "1000 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL1020*\" or NAME==\"*CONTOUR_EL1022*\" or NAME==\"*CONTOUR_EL1024*\" or NAME==\"*CONTOUR_EL1026*\" or NAME==\"*CONTOUR_EL1028*\" or NAME==\"*CONTOUR_EL1030*\" or NAME==\"*CONTOUR_EL1032*\" or NAME==\"*CONTOUR_EL1034*\" or NAME==\"*CONTOUR_EL1036*\" or NAME==\"*CONTOUR_EL1038*\" or NAME==\"*CONTOUR_EL1040*\" or NAME==\"*CONTOUR_EL1042*\" or NAME==\"*CONTOUR_EL1044*\" or NAME==\"*CONTOUR_EL1046*\" or NAME==\"*CONTOUR_EL1048*\" or NAME==\"*CONTOUR_EL1050*\" or NAME==\"*CONTOUR_EL1052*\" or NAME==\"*CONTOUR_EL1054*\" or NAME==\"*CONTOUR_EL1056*\" or NAME==\"*CONTOUR_EL1058*\" or NAME==\"*CONTOUR_EL1060*\" or NAME==\"*CONTOUR_EL1062*\" or NAME==\"*CONTOUR_EL1064*\" or NAME==\"*CONTOUR_EL1066*\"" "1000 LEVEL" "X" nil))

(or(member "1070 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL1070*\" or NAME==\"*CONTOUR_EL1072*\" or NAME==\"*CONTOUR_EL1074*\" or NAME==\"*CONTOUR_EL1076*\" or NAME==\"*CONTOUR_EL1078*\" or NAME==\"*CONTOUR_EL1080*\" or NAME==\"*CONTOUR_EL1082*\" or NAME==\"*CONTOUR_EL1084*\" or NAME==\"*CONTOUR_EL1086*\" or NAME==\"*CONTOUR_EL1088*\" or NAME==\"*CONTOUR_EL1090*\" or NAME==\"*CONTOUR_EL1092*\" or NAME==\"*CONTOUR_EL1094*\" or NAME==\"*CONTOUR_EL1096*\" or NAME==\"*CONTOUR_EL1098*\" or NAME==\"*CONTOUR_EL1100*\" or NAME==\"*CONTOUR_EL1102*\" or NAME==\"*CONTOUR_EL1104*\" or NAME==\"*CONTOUR_EL1106*\" or NAME==\"*CONTOUR_EL1108*\"" "1070 LEVEL" "X" nil))

(or(member "1100 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL1110*\" or NAME==\"*CONTOUR_EL1112*\" or NAME==\"*CONTOUR_EL1114*\" or NAME==\"*CONTOUR_EL1116*\" or NAME==\"*CONTOUR_EL1118*\" or NAME==\"*CONTOUR_EL1120*\" or NAME==\"*CONTOUR_EL1122*\" or NAME==\"*CONTOUR_EL1124*\" or NAME==\"*CONTOUR_EL1126*\" or NAME==\"*CONTOUR_EL1128*\" or NAME==\"*CONTOUR_EL1130*\" or NAME==\"*CONTOUR_EL1132*\" or NAME==\"*CONTOUR_EL1134*\" or NAME==\"*CONTOUR_EL1136*\" or NAME==\"*CONTOUR_EL1138*\" or NAME==\"*CONTOUR_EL1140*\" or NAME==\"*CONTOUR_EL1142*\" or NAME==\"*CONTOUR_EL1144*\" or NAME==\"*CONTOUR_EL1146*\" or NAME==\"*CONTOUR_EL1148*\" or NAME==\"*CONTOUR_EL1150*\" or NAME==\"*CONTOUR_EL1152*\" or NAME==\"*CONTOUR_EL1154*\" or NAME==\"*CONTOUR_EL1156*\" or NAME==\"*CONTOUR_EL1158*\" or NAME==\"*CONTOUR_EL1160*\" or NAME==\"*CONTOUR_EL1162*\" or NAME==\"*CONTOUR_EL1164*\" or NAME==\"*CONTOUR_EL1166*\" or NAME==\"*CONTOUR_EL1168*\"" "1100 LEVEL" "X" nil))

(or(member "1150 LEVEL" names)(command "._-layer" "filter" "new" "property" "All" "NAME==\"*CONTOUR_EL1170*\" or NAME==\"*CONTOUR_EL1172*\" or NAME==\"*CONTOUR_EL1174*\" or NAME==\"*CONTOUR_EL1176*\" or NAME==\"*CONTOUR_EL1178*\" or NAME==\"*CONTOUR_EL1180*\" or NAME==\"*CONTOUR_EL1182*\" or NAME==\"*CONTOUR_EL1184*\" or NAME==\"*CONTOUR_EL1186*\" or NAME==\"*CONTOUR_EL1188*\" or NAME==\"*CONTOUR_EL1190*\" or NAME==\"*CONTOUR_EL1192*\" or NAME==\"*CONTOUR_EL1194*\" or NAME==\"*CONTOUR_EL1196*\" or NAME==\"*CONTOUR_EL1198*\" or NAME==\"*CONTOUR_EL1200*\" or NAME==\"*CONTOUR_EL1202*\" or NAME==\"*CONTOUR_EL1204*\" or NAME==\"*CONTOUR_EL1206*\" or NAME==\"*CONTOUR_EL1208*\" or NAME==\"*CONTOUR_EL1210*\" or NAME==\"*CONTOUR_EL1212*\" or NAME==\"*CONTOUR_EL1214*\" or NAME==\"*CONTOUR_EL1216*\" or NAME==\"*CONTOUR_EL1218*\" or NAME==\"*CONTOUR_EL1220*\" or NAME==\"*CONTOUR_EL1222*\" or NAME==\"*CONTOUR_EL1224*\" or NAME==\"*CONTOUR_EL1226*\" or NAME==\"*CONTOUR_EL1228*\" or NAME==\"*CONTOUR_EL1230*\"" "1150 LEVEL" "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)

 

Edited by ktbjx
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...