filters in Lisp
HiCan somebody please help me on the following problem. I need to filter for all circles below a certain radius, but every time I try examples found on web sites they fail.This is the line I need to add the less than or equal to criteria to.Kim(setq ss (ssget "x" (list (cons 8 layr) (cons 0 "circle") (cons 40 2.3))))
Comments
-
I'm afraid you can't have a "smaller than" filter in a selection set filter list. The filter list matches excact properties only. You first have to build a selection set of circles using the fixed properties you supply (layer and entity type judging by your example). After that you check the radius of each circle in the selection set, if it is a match it is added to a second, final selection set.It is a good practice to define operations like this as functions, to be kept separate from your "main" lisp code (it should be in the same file). This makes the use and reuse of an operation easier.Here is what I'd do: (defun maxrad (layr rad / sstmp cir cnt);;;Create selection set of circle entities on specific layer using logical operators(setq sstmp (ssget "X" (list '(-4 . "<AND") (cons 8 layr) '(0 . "CIRCLE")'(-4 . "AND>"))))(setq ss (ssadd);creates empty selection setcnt 0);new counter(repeat (sslength sstmp)(setq cir (ssname sstmp cnt));a circle in the selection set(if (>= rad (cdr(assoc 40 (entget cir))));test radius(setq ss (ssadd cir ss));add to selection set if it passed test)(setq cnt (1+ cnt));increment counter)ss) To use the function, you must pass arguments to it. Let's say you want circles on layer "Green" with radius smaller than 1.5:(maxrad "Green" 1.5)creates a selection set ss containing all circles on layer "Green" with a radius smaller than or equal to 1.5
0