gsc Posted November 9, 2020 Posted November 9, 2020 Hi, I want to merge 2 selection sets ss2 (e.g. 4 circles) and sel2 (e.g. 1 polyline), but I also want to keep the original selection set ss2 (e.g. 4 circles) So I thought that if I set ss2 equal to sel1 "(setq sel1 ss2)" and use sel1 to add sel2, would work. But apparently selection ss2 also has 5 objects after the ssadd merge, why is that? (setq ss2 (ssget "X" (list (cons 0 "CIRCLE")(cons 8 "97-iac-sz-temp")))) (print (sslength ss2)) ; Returns 4 Objects, which is correct (setq sel1 ss2) (setq sel2 (ssget "X" (list (cons 0 "LWPOLYLINE")(cons 8 "30-iac-safety zones")))) ;Merge Selection Sets (setq num 0) (repeat (sslength sel2) (ssadd (ssname sel2 num) sel1) (setq num (1+ num)) ) (print (sslength ss2)) ; Returns 5 Objects ???? Why? (print (sslength sel1)) ; Returns 5 Objects, which is correct because sel2 has 1 object + 4 circles of sel1 = 5 Quote
marko_ribar Posted November 9, 2020 Posted November 9, 2020 (edited) Both sel1 and ss2 are just variable pointers to the same sel. set object... I'd rather try something like this based on your example : (setq ss2 (ssget "X" (list (cons 0 "CIRCLE")(cons 8 "97-iac-sz-temp")))) (print (sslength ss2)) ; Returns 4 Objects, which is correct (setq sel2 (ssget "X" (list (cons 0 "LWPOLYLINE")(cons 8 "30-iac-safety zones")))) ;Merge Selection Sets (setq sel1 (ssadd)) ; Creating new sel. set object (setq num 0) (repeat (sslength sel2) (ssadd (ssname sel2 num) sel1) (setq num (1+ num)) ) (setq num 0) (repeat (sslength ss2) (ssadd (ssname ss2 num) sel1) (setq num (1+ num)) ) (print (sslength ss2)) ; Returns 4 Objects - it should be like that now (print (sslength sel1)) ; Returns 5 Objects, which is correct because sel2 has 1 object + 4 circles of ss2 = 5 Edited November 9, 2020 by marko_ribar Quote
Lee Mac Posted November 9, 2020 Posted November 9, 2020 I would suggest: (setq ss2 (ssget "_X" '((0 . "CIRCLE") (8 . "97-iac-sz-temp"))) sel1 (ssget "_X" '((-4 . "<OR") (-4 . "<AND") (0 . "LWPOLYLINE") (8 . "30-iac-safety zones") (-4 . "AND>") (-4 . "<AND") (0 . "CIRCLE") (8 . "97-iac-sz-temp") (-4 . "AND>") (-4 . "OR>"))) ) Quote
gsc Posted November 10, 2020 Author Posted November 10, 2020 Thanx for the help, both are working! 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.