Jump to content

Recommended Posts

Posted

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

 

Posted (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 by marko_ribar
Posted

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>")))
)

 

Posted

Thanx for the help, both are working!

 

 

 

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