Author Topic: Partial filter selection ...  (Read 2032 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
Partial filter selection ...
« on: June 25, 2010, 10:37:33 AM »
Good morn'n all,

I have been playing with some code to try and make a partial filter selection, and have run into a (I would think simple) problem.
How can I get a selection thru code, so the items selected are visible much like a window selection around some lines, and then end the code??
Lemme see if I can explain this thoroughly enough for you to understand.
Say you have nine lines in a star pattern.  These lines are each different colors and on different layers.
You want to select only the lines on layer zero that are yellow.  For sake of argument, lets say there are two yellow lines on layer zero out of the nine lines total.
Now, QSelect is a great tool, but can be useless at times, like in this scenario.  I don't want every line in the drawing that is on layer zero and yellow, I only want the two lines that are mixed in with this star pattern.
I could just zoom in on the star pattern and pick the two lines individually, but this is an example of a much larger issue, one that could have as many as 40 lines mixed in the bag.  That would take some time to pick through.
So I want to filter my selection much like SSGET does:
Code: [Select]
(SSGET (list (cons 8 "0")(cons 62 2)))This creates a selection set.

I have been searching for something like a (GETLAST) that would then select the selection set much like picking the individual lines by hand.
I don't know how to terminate the code with the selected lines apparent so I can use the pulldown color control or layer control buttons.

My thoughts are on the narrow side of life, you know the saying; 'Two heads are better than one, four better than two ...' etc.
Perhaps AutoCAD already has a built in command for this kind of thing and I'm just not thinking of it.  I'm focusing more on code than on possible tools currently available.

Anyway, if you have some suggestions regarding this filtered selection you could pass my way, it would be much appreciated.

Thank you very much.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Partial filter selection ...
« Reply #1 on: June 25, 2010, 10:56:16 AM »
I think you want sssetfirst

(defun c:getyellow (/ ss) (setq ss (ssget '((8 . "0") (62 . 2)))) (sssetfirst nil ss))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Partial filter selection ...
« Reply #2 on: June 25, 2010, 11:02:29 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Partial filter selection ...
« Reply #3 on: June 25, 2010, 11:28:27 AM »
I think you want sssetfirst

(defun c:getyellow (/ ss) (setq ss (ssget '((8 . "0") (62 . 2)))) (sssetfirst nil ss))

Yes Ron, that is what I am looking for, Thank you.
I had perused through all the commands, but the name 'sssetfirst' doesn't necessarily reflect it's purpose per-se.  Or at least what I was thinking of, so I went right by it.


CAB,  Excellent examples, Thank you.  These will be very inspirational.
Just a random observation; it's interesting you posted these in 2005 and there's not a single comment in the post.  But that's all right, we all know your awesome anyway.  :wink:


Thanks again guys.  With this new insight, I'm going to rewrite my code for better performance.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hangman

  • Swamp Rat
  • Posts: 566
Re: Partial filter selection ...
« Reply #4 on: June 25, 2010, 02:33:35 PM »
I have come across an interesting thing and would like your input on it.

So I have the values in variables:
Code: [Select]
(setq Object (car (entsel "\nSelect an Object to be changed: ")))
    (setq eList (entget Object))
    (setq objLayer (assoc 8 eList)        ; string
          objColor (assoc 62 eList)       ; integer     (62 . 256) = bylayer
          objLType (assoc 6 eList)        ; string      (6 . "bylayer") = bylayer
          objLWght (assoc 370 eList)      ; integer !!  (370 . -1) = bylayer
    )
And I want to select some lines by filtering:
Code: [Select]
(setq obj-to-change (ssget (list objLayer)))
This works just fine.

But this ...
Code: [Select]
(setq obj-to-change (ssget (list objLayer)
                                       (list objColor)
                                )
            )
Does not.

Why does SSGET work with one listed variable, but not with two or more ??
What syntax is missing to make this work this way ??


I know I can go back and redo the code like so:
Code: [Select]
(setq Object (car (entsel "\nSelect an Object to be changed: ")))
    (setq eList (entget Object))
    (setq objLayer [color=red](cdr [/color] (assoc 8 eList)        ; string
          objColor [color=red](cdr [/color] (assoc 62 eList)       ; integer     (62 . 256) = bylayer
          objLType [color=red](cdr [/color] (assoc 6 eList)        ; string      (6 . "bylayer") = bylayer
          objLWght [color=red](cdr [/color] (assoc 370 eList)      ; integer !!  (370 . ???)
    )
And then ...
Code: [Select]
(setq obj-to-change (ssget (list [color=red](cons 8 [/color] objLayer)
                                       (list [color=red](cons 62 [/color] objColor)
                                )
            )

But I don't necessarily want to do this change if I can avoid it.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Partial filter selection ...
« Reply #5 on: June 25, 2010, 02:55:44 PM »
But this ...
Code: [Select]
(setq obj-to-change (ssget (list objLayer)
                                       (list objColor)
                                )
            )
Does not.

Your problem is with the two list and should be one, like this:
Code: [Select]
(setq obj-to-change (ssget (list objLayer objColor) ) )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Partial filter selection ...
« Reply #6 on: June 25, 2010, 02:58:09 PM »
Also code 62 is not present for items that are color bylayer.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC