Author Topic: Get 2 selection sets from 1 selection?  (Read 1090 times)

0 Members and 1 Guest are viewing this topic.

qwrtz

  • Newt
  • Posts: 22
Get 2 selection sets from 1 selection?
« on: May 07, 2016, 01:18:56 AM »
I can prompt for a selection set and filter it for a block named "510".
Code: [Select]
(setq ET "INSERT") (setq PR (cons 0 ET)) (setq BL1 "510")
(setq ss0 (ssget (list PR)))
(setq ss1 (ssget "P" (list (cons 2 BL1))))
And then I can prompt for another selection set and filter it for a block named "515".
Code: [Select]
(setq ET "INSERT") (setq PR (cons 0 ET)) (setq BL2 "515")
(setq ss0 (ssget (list PR)))
(setq ss2 (ssget "P" (list (cons 2 BL2))))
But I'd like to prompt for a selection set only once, and get both ss1 and ss2 from that single user input.
Is that possible? Can I get ss0 from the user and then create both ss1 and ss2 from it?

BlackBox

  • King Gator
  • Posts: 3770
Re: Get 2 selection sets from 1 selection?
« Reply #1 on: May 07, 2016, 02:42:55 AM »
You can prompt the user for a single selections set that filters for "510,515" - then iterate that selection set using a COND, or IF statement to handle each accordingly.


Cheers
"How we think determines what we do, and what we do determines what we get."

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: Get 2 selection sets from 1 selection?
« Reply #2 on: May 07, 2016, 03:00:46 AM »
Perhaps something like this ?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test2 (/ bl1 bl2 e i ss0 ssbl1 ssbl2 x)
  2.   (setq BL1   "510"
  3.         BL2   "515"
  4.         ssBL1 (ssadd)
  5.         ssBL2 (ssadd)
  6.   )
  7.   (if (setq ss0 (ssget (list '(0 . "INSERT") (cons 2 (strcat BL2 "," BL1)))))
  8.     (progn (setq i 0)
  9.            (repeat (sslength ss0)
  10.              (setq e (ssname ss0 i)
  11.                    x (cdr (assoc 2 (entget e)))
  12.                    i (1+ i)
  13.              )
  14.              (if (= x BL1)
  15.                (ssadd e ssBL1)
  16.                (ssadd e ssBL2)
  17.              )
  18.            )
  19.     )
  20.   )
  21.   (princ)
  22. )
  23.  
  24.  
« Last Edit: May 07, 2016, 03:05:28 AM by kdub »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

qwrtz

  • Newt
  • Posts: 22
Re: Get 2 selection sets from 1 selection?
« Reply #3 on: May 07, 2016, 10:49:03 AM »
Thanks very much! That's just what I needed.