lido Posted March 27, 2019 Posted March 27, 2019 Hello everyone. I have tried to select all entities in the current workspace based on the properties in the ent_list list (see an example below). I notice that the ent_list could contain several names of entities and/or other properties thereof. ;| ent_list example (((0 . "CIRCLE") (8 . "R_30m") (62 . 7) (410 . "Model")) ((0 . "MTEXT") (8 . "Pen_No__12") (62 . 3) (410 . "Model")) ((0 . "LWPOLYLINE") (8 . "Limits") (62 . 256) (410 . "Model")) ((0 . "LWPOLYLINE") (8 . "Pen_No__1") (62 . 5) (410 . "Model")) ((0 . "LINE") (8 . "Pen_No__7") (62 . 256) (410 . "Model")) ((0 . "ARC") (8 . "Pen_No__31") (62 . 256) (410 . "Model"))) |; ;;This returns nil: (setq S_LIGH (ssget "_X" (append (cons '(-4 . "<and") ent_list) (list '(-4 . "and>"))))) So I found a "bypass route" but I do not like the solution (see below). (setq SS_LST (mapcar (function (lambda (x) (ssget "_X" x))) ent_list)) ;| Returns: ( <Selection Set: ff8b7860> <Selection Set: ff8b7820> <Selection Set: ff8b7940> <Selection Set: ff8b79a0> <Selection Set: ff8b77e0> <Selection Set: ff8b79c0>) |; (setq S_LIGH (if (= (length SS_LST) 1) (car SS_LST) ;;https://www.cadtutor.net/forum/topic/39716-how-to-join-selection-sets/ ;; Selection Set Union - Lee Mac ;; Returns the union of a list of Selection Sets (LM:ss-union SS_LST) ;;Returns <Selection Set: ff8b7940> ) ) Another approach or idea? Thank you in advance. Quote
Lee Mac Posted March 27, 2019 Posted March 27, 2019 (edited) You'll need to use OR logic between each group of properties, and AND logic between the properties within the group, e.g.: (setq s_ligh (ssget "_X" (append '((-4 . "<OR")) (apply 'append (mapcar '(lambda ( x ) (append '((-4 . "<AND")) x '((-4 . "AND>")))) ent_list)) '((-4 . "OR>")) ) ) ) Edited March 27, 2019 by Lee Mac 1 1 Quote
lido Posted March 28, 2019 Author Posted March 28, 2019 @ronjonp 1. Need for speed. 2. I want to avoid using a large number of selection sets. @Lee Mac Thank you for your solution. It works fine. Quote
Lee Mac Posted March 28, 2019 Posted March 28, 2019 9 hours ago, lido said: @Lee Mac Thank you for your solution. It works fine. Excellent to hear - you're welcome 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.