Jump to content

ssget with filter


lido

Recommended Posts

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.

Link to comment
Share on other sites

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 by Lee Mac
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...