Selection filter
Is there a similar powerfull tool for filtering selection as the FILTER command in ACAD? I know the "Properties" option in "Select entities" dialog but it is very limited - e.g. I can't select only circles with given radius on a specific layer (or with a specific color) etc. I think it should be possible to have a routine written in Lisp to do this. Before even trying to write it, I would like to know if it already exists. Any suggestions?RegardsVaclav
Comments
-
Don't understand why this is not implemented as a standard option. To make "complicated" selections on multiple properties i still go back to ACAD.Or am i missing something, somewhere?Regards,Florian
0 -
I'm going to try to port filter.lsp and filter.dcl from autocad R14 or 2000 to use in bricscad. I tried it just now and the dcl doesn't come up. I'll work on it in the few weeks. I really need it. I'll share the results.
0 -
Sounds goog Yaacov,I'll be happy to hear the results.
0 -
I developed aes-styled lisp routines to filter entities without the trouble to go through selection dialog.ex. del lin . or mov insert dx 5000, etc.It is quite handy if you have overlapping entities to delete or move.Send me a mail if you need it.jbj
0 -
There is an old and proven lisp routine that works fine on all versions of Autocad and Bricsys. here it is:;;; ssx.lsp;;; Copyright (C) 1990 by Autodesk, Inc.;;;;;; Permission to use, copy, modify, and distribute this software and its;;; documentation for any purpose and without fee is hereby granted.;;;;;; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.;;; ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF;;; MERCHANTABILITY ARE HEREBY DISCLAIMED.;;;;;; Larry Knott Version 2.0 7/18/88;;; Carl Bethea & Jan S. Yoder Version 3.0;;; Enhancements to (ssx).;;; 15 March 1990;;;;;;--------------------------------------------------------------------------;;;; DESCRIPTION;;; SSX.LSP;;;;;; "(SSX)" - Easy SSGET filter routine.;;;;;; Creates a selection set. Either type "SSX" at the "Command:" prompt;;; to create a "previous" selection set or type "(SSX)" in response to;;; any "Select objects:" prompt. You may use the functions "(A)" to add;;; entities and "(R)" to remove entities from a selection set during;;; object selection. More than one filter criteria can be used at a;;; time.;;;;;; SSX returns a selection set either exactly like a selected;;; entity or, by adjusting the filter list, similar to it.;;;;;; The initial prompt is this:;;;;;; Command: ssx;;; Select object/: (RETURN);;; >>Block name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector:;;;;;; Pressing RETURN at the initial prompt gives you a null selection;;; mechanism just as (ssx) did in Release 10, but you may select an;;; entity if you desire. If you do so, then the list of valid types;;; allowed by (ssget "x") are presented on the command line.;;;;;; Select object/: (a LINE selected);;; Filter: ((0 . "LINE") (8 . "0") (39 . 2.0) (62 . 1) (210 0.0 0.0 1.0));;; >>Block name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector:;;;;;; At this point any of these filters may be removed by selecting the;;; option keyword, then pressing RETURN.;;;;;; >>Layer name to add/: (RETURN);;;;;; Filter: ((0 . "LINE") (39 . 2.0) (62 . 1) (210 0.0 0.0 1.0));;; >>Block name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector:;;;;;; If an item exists in the filter list and you elect to add a new item,;;; the old value is overwritten by the new value, as you can have only;;; one of each type in a single (ssget "x") call.;;;;;;--------------------------------------------------------------------------;;;;;;; Find the dotted pairs that are valid filters for ssget;;; in entity named "ent".;;;;;; ssx_fe == SSX_Find_Entity;;;(defun ssx_fe (/ x data fltr ent) (setq ent (car (entsel "\nSelect object/: "))) (if ent (progn (setq data (entget ent)) (foreach x '(0 2 6 7 8 39 62 66 210) ; do not include 38 (if (assoc x data) (setq fltr (cons (assoc x data) fltr) ) ) ) (reverse fltr) ) ));;;;;; Remove "element" from "alist".;;;;;; ssx_re == SSX_Remove_Element;;;(defun ssx_re (element alist) (append (reverse (cdr (member element (reverse alist)))) (cdr (member element alist)) ));;;;;; INTERNAL ERROR HANDLER;;;(defun ssx_er (s) ; If an error (such as CTRL-C) occurs ; while this command is active... (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) ) (if olderr (setq error olderr)) ; Restore old error handler (princ));;;;;; Get the filtered sel-set.;;;;;;(defun ssx (/ olderr) (gc) ; close any sel-sets (setq olderr error error ssx_er ) (setq fltr (ssx_fe)) (ssx_gf fltr));;;;;; Build the filter list up by picking, selecting an item to add,;;; or remove an item from the list by selecting it and pressing RETURN.;;;;;; ssx_gf == SSX_Get_Filters;;;(defun ssx_gf (f1 / t1 t2 t3 f1 f2) (while (progn (cond (f1 (prompt "\nFilter: ") (prin1 f1))) (initget "Block Color Entity Flag LAyer LType Pick Style Thickness Vector") (setq t1 (getkword (strcat "\n>>Block name/Color/Entity/Flag/" "LAyer/LType/Pick/Style/Thickness/Vector: "))) ) (setq t2 (cond ((eq t1 "Block") 2) ((eq t1 "Color") 62) ((eq t1 "Entity") 0) ((eq t1 "LAyer") 8) ((eq t1 "LType") 6) ((eq t1 "Style") 7) ((eq t1 "Thickness") 39) ((eq t1 "Flag" ) 66) ((eq t1 "Vector") 210) (T t1) ) ) (setq t3 (cond ((= t2 2) (getstring "\n>>Block name to add/: ")) ((= t2 62) (initget 4 "?") (cond ((or (eq (setq t3 (getint "\n>>Color number to add/?/: ")) "?") (> t3 256)) (ssx_pc) ; Print color values. nil ) (T t3 ; Return t3. ) ) ) ((= t2 0) (getstring "\n>>Entity type to add/: ")) ((= t2 8) (getstring "\n>>Layer name to add/: ")) ((= t2 6) (getstring "\n>>Linetype name to add/: ")) ((= t2 7) (getstring "\n>>Text style name to add/: ") ) ((= t2 39) (getreal "\n>>Thickness to add/: ")) ((= t2 66) (if (assoc 66 f1) nil 1)) ((= t2 210) (getpoint "\n>>Extrusion Vector to add/: ") ) (T nil) ) ) (cond ((= t2 "Pick") (setq f1 (ssx_fe) t2 nil)) ; get entity ((and f1 (assoc t2 f1)) ; already in the list (if (and t3 (/= t3 "")) ;; Replace with a new value... (setq f1 (subst (cons t2 t3) (assoc t2 f1) f1)) ;; Remove it from filter list... (setq f1 (ssx_re (assoc t2 f1) f1)) ) ) ((and t3 (/= t3 "")) (setq f1 (cons (cons t2 t3) f1)) ) (T nil) ) ) (if f1 (setq f2 (ssget "x" f1))) (setq error olderr) (if (and f1 f2) (progn (princ (strcat "\n" (itoa (sslength f2)) " found. ")) (if (= 0 (getvar "cmdactive")) ;; ssget doesn't set previous !! (command "select" f2 "")) ;; for now. !! f2 ) (progn (princ "\n0 found.") (prin1)) ));;;;;; Print the standard color assignments.;;;;;;(defun ssx_pc () (if textpage (textpage) (textscr)) (princ "\n ") (princ "\n Color number | Standard meaning ") (princ "\n ________________|____________________") (princ "\n | ") (princ "\n 0 | ") (princ "\n 1 | Red ") (princ "\n 2 | Yellow ") (princ "\n 3 | Green ") (princ "\n 4 | Cyan ") (princ "\n 5 | Blue ") (princ "\n 6 | Magenta ") (princ "\n 7 | White ") (princ "\n 8...255 | -Varies- ") (princ "\n 256 | ") (princ "\n \n\n\n"));;;;;; C: function definition.;;;(defun c:ssx () (ssx)(princ))(princ "\n\tType \"ssx\" at a Command: prompt or ")(princ "\n\t(ssx) at any object selection prompt. ")(princ)
0 -
Thanks, Yaacov, but I couldn't get ssx.lsp to work in v8.0.21. What version did you use it in?It is possible to use the built-in Select tool to screen for multiple properties. You "Select by Properties" for the first property, let's say color, and then click "Subtract from Set" and pick the next property, say type or layer, and so on.But radius isn't one of the properties you can select.
0 -
This is a little routine i have done some years ago. It works fine for me again under Bricscad V7 (Try it under V8 and let me know)Put these lines now in a file called FILTERW.LSP(If you want select colors, tape 62, etc...);FILTERW.LSP -VER 1.0- Filter objects in a drawing with WINDOW or CROSSING;By Richard Stas - 10 Nov 95;Compuserve # 100451,2643;This little routine can select objects that you want in a drawing and put this;selection in S2. After that, if you use the command CHANGE or other, tap !S2;in reply at the phrase "select object:";******************************************************************************(defun C:Win (/ cd tn par s1 n i e oal oeb ename m) (setq cd (getint "\nEnter Associative Code -> [ EntityType-0, Block-2, LineType-6, LayerName-8, Radius-40, Color-62,]:")) (initget 1 "T N") (setq tn (getkword "\nParameter (T)ext or (N)umber: ")) (setq tn (strcase tn)) (if (= tn "T") (progn (setq par (getstring "\nEnter Text Parameter [Hatch =`X] : ")) (setq par (strcase par)) ) ) (if (= tn "N") (progn (setq par (getint "\nEnter Number Parameter: ")) ) ) (setq s1 (ssget)) (setq n (sslength s1)) (setq s2 (ssadd)) (setq i 0) (setq rst n) (repeat n (setq e (entget (ssname s1 i))) (setq i (+ i 1)) (setq oal (assoc cd e)) (setq oeb (assoc -1 e)) (setq ename (cdr oeb)) (if (= par (cdr oal)) (progn (setq s2 (ssadd ename s2)) ) ) (setq rst (- rst 1)) (Princ "\nObjects to be analysed: ") (prompt (rtos rst 2 4)) ) (setq m (sslength s2)) (Princ "\nNumber of objects selected is ") (prompt (rtos m 2 4)) (Prompt "\nDone... Tap !S2 after your next command - By richard Stas - 10/11/95") (princ))
0 -
This is a little routine i have done some years ago. It works fine for me again under Bricscad V7 (Try it under V8 and let me know)Put these lines now in a file called FILTERW.LSP(If you want select colors, tape 62, etc...);FILTERW.LSP -VER 1.0- Filter objects in a drawing with WINDOW or CROSSING;By Richard Stas - 10 Nov 95;Compuserve # 100451,2643;This little routine can select objects that you want in a drawing and put this;selection in S2. After that, if you use the command CHANGE or other, tap !S2;in reply at the phrase "select object:";******************************************************************************(defun C:Win (/ cd tn par s1 n i e oal oeb ename m) (setq cd (getint "\nEnter Associative Code -> [ EntityType-0, Block-2, LineType-6, LayerName-8, Radius-40, Color-62,]:")) (initget 1 "T N") (setq tn (getkword "\nParameter (T)ext or (N)umber: ")) (setq tn (strcase tn)) (if (= tn "T") (progn (setq par (getstring "\nEnter Text Parameter [Hatch =`X] : ")) (setq par (strcase par)) ) ) (if (= tn "N") (progn (setq par (getint "\nEnter Number Parameter: ")) ) ) (setq s1 (ssget)) (setq n (sslength s1)) (setq s2 (ssadd)) (setq i 0) (setq rst n) (repeat n (setq e (entget (ssname s1 i))) (setq i (+ i 1)) (setq oal (assoc cd e)) (setq oeb (assoc -1 e)) (setq ename (cdr oeb)) (if (= par (cdr oal)) (progn (setq s2 (ssadd ename s2)) ) ) (setq rst (- rst 1)) (Princ "\nObjects to be analysed: ") (prompt (rtos rst 2 4)) ) (setq m (sslength s2)) (Princ "\nNumber of objects selected is ") (prompt (rtos m 2 4)) (Prompt "\nDone... Tap !S2 after your next command - By richard Stas - 10/11/95") (princ))
0 -
This is a little routine i have done some years ago. It works fine for me again under Bricscad V7 (Try it under V8 and let me know)Put these lines now in a file called FILTERW.LSP(If you want select colors, tape 62, etc...);FILTERW.LSP -VER 1.0- Filter objects in a drawing with WINDOW or CROSSING;By Richard Stas - 10 Nov 95;Compuserve # 100451,2643;This little routine can select objects that you want in a drawing and put this;selection in S2. After that, if you use the command CHANGE or other, tap !S2;in reply at the phrase "select object:";******************************************************************************(defun C:Win (/ cd tn par s1 n i e oal oeb ename m) (setq cd (getint "\nEnter Associative Code -> [ EntityType-0, Block-2, LineType-6, LayerName-8, Radius-40, Color-62,]:")) (initget 1 "T N") (setq tn (getkword "\nParameter (T)ext or (N)umber: ")) (setq tn (strcase tn)) (if (= tn "T") (progn (setq par (getstring "\nEnter Text Parameter [Hatch =`X] : ")) (setq par (strcase par)) ) ) (if (= tn "N") (progn (setq par (getint "\nEnter Number Parameter: ")) ) ) (setq s1 (ssget)) (setq n (sslength s1)) (setq s2 (ssadd)) (setq i 0) (setq rst n) (repeat n (setq e (entget (ssname s1 i))) (setq i (+ i 1)) (setq oal (assoc cd e)) (setq oeb (assoc -1 e)) (setq ename (cdr oeb)) (if (= par (cdr oal)) (progn (setq s2 (ssadd ename s2)) ) ) (setq rst (- rst 1)) (Princ "\nObjects to be analysed: ") (prompt (rtos rst 2 4)) ) (setq m (sslength s2)) (Princ "\nNumber of objects selected is ") (prompt (rtos m 2 4)) (Prompt "\nDone... Tap !S2 after your next command - By richard Stas - 10/11/95") (princ))
0 -
Sorry, my message was sent 3 times by errorRSTAS
0 -
Sorry, my message was sent 3 times by errorRSTAS
0 -
There is again another routine i found in my attic.More precise than the previous i posted.;TIP1356.LSP: SSS.LSP Select Entities by Properties (c)1997,V. Levin(defun c:SSS (/ sst p1 p2 et cr crit crkw e ssl) (setvar "cmdecho" 0) (graphscr) (initget "ALL W C") (setq sst (getkword "\n Select type of search - Window/Crossing/ : ") et 1 ) (if (= sst "ALL") (setq sst nil)) (if sst (progn (initget 1) (setq p1 (getpoint "\n First corner: ")) (initget 1) (setq p2 (getcorner p1 "\n Second corner: ")) ) ) (while (= et 1) (initget "TEXT,T PLINE,PL LINE,L CIRCLE,C BLOCK,B POINT,P ALL ATTDEF,A") (setq et (entsel "\n Search for - Text/Attdef/PLine/Line/Circle/Point/Block/ - PICK: ")) (if (not et) (if (= (getvar "errno") 7) (progn (setq et 1) (prompt "\n Nothing found. Try again...") ) ) (if (listp et) (setq et (cdr (assoc 0 (entget (car et))))) ) ) ) (prompt (strcat "\n Selected: " (if et (if (= et "INSERT") "BLOCK" et) "ALL" ) ) ) (setq et (cond ((= et "PLINE") "POLYLINE") ((= et "BLOCK") "INSERT") ((or (not et)(= et "ALL")) "") (T et) ) cr "\n Search under what critiria - " crit "Layer/LType/Color/Elevation/: " crkw "Layer LType Color Elevation ALL" crit (cond ((= et "INSERT") (initget (strcat crkw " Name")) (getkword (strcat cr "Name/" crit)) ) ((= et "POLYLINE") (initget (strcat crkw " Width")) (getkword (strcat cr "Width/" crit)) ) ((or (= et "TEXT") (= et "ATTDEF")) (initget (strcat crkw " STring Style Height Rotation Width")) (getkword (strcat cr "Style/STring/Height/Rotation/Width/" crit)) ) (T (initget crkw) (getkword (strcat cr crit)) ) ) crkw (if crit (strcase crit)) crit nil )(defun LALTCF (x) (setq crit "") (while (= crit "") (setq crit (strcase (getstring (strcat "\n " x " name / : ")))) (if (= crit "") (PICKF) (if (not (or (wcmatch crit "]") (tblsearch crkw crit) ) ) (progn (prompt (strcat "\n " x " [" crit "] does not exist. Try again...")) (setq crit "") ) ) ) )) (cond ((= crkw "LAYER") (setq cr 8) (LALTCF "Layer") ) ((= crkw "LTYPE") (setq cr 6) (LALTCF "Linetype") ) ((= crkw "NAME") (setq cr 2) (LALTCF "Block") ) ((= crkw "STYLE") (setq cr 7) (LALTCF "Text style") ) ((= crkw "STRING") (setq crit (getstring "\n Text string to match: ") crit (strcat "" crit "") cr 1 ) ) ((= crkw "COLOR") (setq cr 62) (while (not crit) (setq crit (getint "\n Color number [0...256] / : ")) (if crit (if (not (<= 0 crit 256)) (progn (prompt "\n ERROR: Value is out of range. Try again...") (setq crit nil) ) ) (PICKF) ) ) ) ((= crkw "WIDTH") (setq cr 41) (while (not crit) (initget 4) (setq crit (getdist (strcat "\n " et " width / : "))) (if (not crit) (PICKF)) ) ) ((= crkw "ELEVATION") (setq cr 38) (while (not crit) (setq crit (getdist "\n Elevation / : ")) (if (not crit) (PICKF)) ) ) ((= crkw "HEIGHT") (setq cr 40) (while (not crit) (initget 4) (setq crit (getdist "\n Text height / : ")) (if (not crit) (PICKF)) ) ) ((= crkw "ROTATION") (setq cr 50) (while (not crit) (setq crit (getangle "\n Text rotation angle in degrees / : ")) (if (not crit) (PICKF)) ) ) (T (setq cr 8 crit "*")) ) (setq crkw nil) (if (member cr '(38 40 41 50)) (progn (initget "= E /= < > <= >=") (setq crkw (getkword "\n Range of values - [/=] / [<] / [>] / [<=] / [>=] / : ")) (if (or (not crkw) (= crkw "E")) (setq crkw "=")) (setq crkw (cons -4 crkw)) ) ) (setq ssl (list (cons cr crit))) (if crkw (setq ssl (cons crkw ssl))) (setq ssl (cons (cons 0 et) ssl) ss (if sst (ssget sst p1 p2 ssl) (ssget "x" ssl)) ) (if ss (progn (command ".select" ss "") (setq ssl (sslength ss)) (prompt (strcat "\n Variable 'ss' defined - " (itoa ssl) " entit" (if (= ssl 1) "y" "ies") " found.")) ) (prompt "\n Nothing found.") ) (princ))(defun PICKF ( / e) (setq e (entsel (strcat "\n Pick " (cond ((= cr 2) "Block") ((member cr '(6 8 38 62)) "Entity") (T et) ) (if (= cr 8) " on" " with") " desired " crkw ": " ) ) ) (if e (progn (setq e (entget (car e))) (if (or (member cr '(6 8 38 62)) (= (cdr (assoc 0 e)) et) ) (progn (setq crit (cdr (assoc cr e))) (if (not crit) (setq crit (cond ((= cr 6) "BYLAYER") ((= cr 62) 256) (T 0) ) ) ) (prompt (strcat "\n Selected: " (cond ((= cr 62) (cond ((= crit 0) "BYBLOCK") ((= crit 256) "BYLAYER") (T (strcat "#" (itoa crit))) ) ) ((numberp crit) (rtos crit)) (T crit) ) ) ) ) (prompt (strcat "\n Selected entity is not a" (if (= et "ATTDEF") "n " " ") (if (= cr 2) "BLOCK" et) ". Try again..." ) ) ) ) (prompt "\n Nothing found. Try again...") ))(prompt "\n SSS - Selects entities by properties.")(princ)
0