lastknownuser Posted December 14, 2021 Posted December 14, 2021 I have a question, if it is even possible. For example, I want to select part of my drawing that contains lines and points (ssget_test). Is it possible to extract two selection sets, one with just lines (ss_lines) and other with points (ss_points), from that first selection set (ssget_test)? Basically to filter the selection set by cons 0 Quote
Trudy Posted December 14, 2021 Posted December 14, 2021 This may help you http://www.lee-mac.com/ssget.html Quote
lastknownuser Posted December 14, 2021 Author Posted December 14, 2021 I have tried looking there, but didn't find needed. Or maybe I don't know what I need to look for exactly. The idea is to use only one ssget and select multiple objects (select only once). And then get selection sets, for example: sel1 (cons 0 "INSERT"), sel2 (cons 0 "LINE"), etc Quote
Tharwat Posted December 14, 2021 Posted December 14, 2021 Basic example for you to get start with. (if (setq ss (ssget '((0 . "LINE,POINT")))) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i))))) (if (= (cdr (assoc 0 e)) "LINE") ;; then do your stuff here for lines ;; else is point object so do your stuff for points. ) ) ) 1 1 Quote
lastknownuser Posted December 14, 2021 Author Posted December 14, 2021 24 minutes ago, Tharwat said: Basic example for you to get start with. (if (setq ss (ssget '((0 . "LINE,POINT")))) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i))))) (if (= (cdr (assoc 0 e)) "LINE") ;; then do your stuff here for lines ;; else is point object so do your stuff for points. ) ) ) Ok thank you, that idea has crossed my mind, but I thought maybe I could get selection set from selection set based on "cons 0" filter. Quote
Tharwat Posted December 14, 2021 Posted December 14, 2021 This: (ssget '((0 . "LINE,POINT"))) Similar to this : (ssget (list (cons 0 "LINE,POINT"))) Quote
dexus Posted December 14, 2021 Posted December 14, 2021 (edited) You can loop though the selectionset and create two new ones with the items filtered like this. This is only better if you use the whole set later, otherwise its an extra step from the solution Tharwat posted (if (setq ss (ssget '((0 . "LINE,POINT")))) (progn (setq lines (ssadd) ; Create empty selectionset points (ssadd) ; Create empty selectionset counter 0) (repeat (setq i (sslength ss)) ; Loop through selectionset and split into two sets (setq e (ssname ss (setq i (1- i)))) (if (eq (cdr (assoc 0 (entget e))) "LINE") ; Decide which set to add to. (ssadd e lines) (ssadd e points) ) ) (setq ss nil) ; Remove origional set ; So stuff with lines-selectionset and points-selectionset )) Edited December 14, 2021 by dexus 1 Quote
lastknownuser Posted December 14, 2021 Author Posted December 14, 2021 23 minutes ago, dexus said: You can loop though the selectionset and create two new ones with the items filtered like this. This is only better if you use the whole set later, otherwise its an extra step from the solution Tharwat posted (if (setq ss (ssget '((0 . "LINE,POINT")))) (progn (setq lines (ssadd) ; Create empty selectionset points (ssadd) ; Create empty selectionset counter 0) (repeat (setq i (sslength ss)) ; Loop through selectionset and split into two sets (setq e (ssname ss (setq i (1- i)))) (if (eq (cdr (assoc 0 (entget e))) "LINE") ; Decide which set to add to. (ssadd e lines) (ssadd e points) ) ) (setq ss nil) ; Remove origional set ; So stuff with lines-selectionset and points-selectionset )) Thanks! I'll try to use that method, since I am trying to modify my current code that has sets that are used later, and there are much more filters than just lines and points like I gave an example here. This way I don't have to change too much. Thanks again, hope it will work when I test it tomorrow Quote
BIGAL Posted December 14, 2021 Posted December 14, 2021 Like Dexus you can use a COND rather than a IF (setq obj (cdr (assoc 0 (entget e)))) (cond ((= obj "LINE")(ssadd e lines)) ((= obj "POINT")(ssadd e points)) ((= obj "LWPOLYLINE")(ssadd e plines)) other objects ) 1 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.