bobsun Posted August 16, 2011 Posted August 16, 2011 Hi, Does there exist any “object filter” ability in AutoCAD? Each AutoCAD file might contain as many as hundreds of individual elements, and each has different property. There might frequently arise needs to: Select all objects on a single layer Select all objects whose color are blue Select all annotative objects. How to address these needs? If by eye inspection and manual selection, it is very inefficient and error-prone. Is there a way to done this automatically using some sort of query language? Bob Quote
dbroada Posted August 16, 2011 Posted August 16, 2011 not sure about option 3 but QSELECT will pick up the others. You could also try FILTER but I have never used that so can't personally comment. Failing that a selection set in any of the programming languages will also allow you to create sets on those parameters. I prefer VBA but LISP is probably more efficient for selection sets. Quote
bobsun Posted August 16, 2011 Author Posted August 16, 2011 QSELECT did the job, thanks. I also tried FILTER and it appeared to be more complicated so I didn't pursue it further. Bob Quote
tzframpton Posted August 16, 2011 Posted August 16, 2011 QSELECT did the job, thanks. I also tried FILTER and it appeared to be more complicated so I didn't pursue it further. Bob Just a tip, even though it looks more difficult, FILTER has many more advantages than QSELECT. For one, you can actually save selection sets for future use. That's a big one for me. Quote
rkmcswain Posted August 16, 2011 Posted August 16, 2011 What Tannar said..... Remember, with complexity comes versatility.... 2. Select all objects whose color are blue Remember that by default, neither QSELECT or FILTER will select objects that appear blue because they reside on a "blue" layer, and their actual color is "bylayer". Quote
bobsun Posted August 16, 2011 Author Posted August 16, 2011 Just a tip, even though it looks more difficult, FILTER has many more advantages than QSELECT. For one, you can actually save selection sets for future use. That's a big one for me. This could be useful. Thanks for reminding. Quote
bobsun Posted August 16, 2011 Author Posted August 16, 2011 What Tannar said.....Remember, with complexity comes versatility.... Remember that by default, neither QSELECT or FILTER will select objects that appear blue because they reside on a "blue" layer, and their actual color is "bylayer". I see it, many thanks. Bob Quote
irneb Posted August 16, 2011 Posted August 16, 2011 (edited) Yep the only way to select all "Blue" entities (even those which are ByLayer on a Blue layer) would be with some coding (probably Lisp). The Filter is even more nice in that it remembers the previous filter by default, i.e. type 'Filter and click OK, instead of going though all the steps again using QSelect. BTW, for me the simplest way of using Filter is to use the "Add Selected Object" button at the bottom left and pick one of the entities I want to select. Then Delete the lines in the top list which aren't needed. For a lisp which selects all entities displayed as Blue: (defun FilterForColor (col / lay llst) (setq llst "") (while (setq lay (tblnext "LAYER" (not lay))) (if (= (cdr (assoc 62 lay)) col) (setq llst (strcat llst "," (cdr (assoc 2 lay)))) ) ) (setq llst (substr llst 2)) (append (list '(-4 . "<OR") (cons 62 col)) (if (eq llst "") '((62 . 256)) (list '(-4 . "<AND") '(62 . 256) (cons 8 llst) '(-4 . "AND>")) ) '((-4 . "OR>")) ) ) (defun c:SelectBlue (/) (sssetfirst nil (ssget "_X" (FilterForColor col))) (princ) ) You can do similar for Layers, and to select all annotative stuff: (defun c:SelectAnno (/) (sssetfirst nil (ssget "_X" '((-3 ("AcadAnnotative"))))) (princ) ) And to combine the 2: (defun c:SelectBlueAnno (/) (sssetfirst nil (ssget "_X" (append (FilterForColor 5) '((-3 ("AcadAnnotative")))))) (princ) ) Edited August 16, 2011 by irneb Simplified code Quote
bobsun Posted August 17, 2011 Author Posted August 17, 2011 irneb, It is a little bit overwhelming for me but I will definitely note it down to study later. Bob Quote
Jeff H Posted August 17, 2011 Posted August 17, 2011 I never knew about the filter command and thats a neat tool Here is a start Using filter command that selects all objects --- On a layer with color blue and the object is set to Bylayer (in this example Layer1 and layer2 color is blue) or --- The object color's property is set to blue. It filters by if the objects color property is blue or if it is on any layer that is blue and it set to bylayer Quote
irneb Posted August 17, 2011 Posted August 17, 2011 That's exactly what my lisp does. It's just that the lisp figures out for itself which layers are set to blue. Using filter you need to remember the layer names. Quote
Recommended Posts
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.