Jump to content

Why does ssdel remove entities from other selection sets, and how to get around it?


benhubel

Recommended Posts

I am writing a routine that requires that I remove objects from a selection set while still keeping the original set around. After running into issues, I created a test routine to see how ssdel is operating. I want it to remove selB from selC, while keeping selA and selD untouched to hold the original selection. It is removing selB from all related selection sets though. Why is it doing this, and how can I fix it?

 

(defun c:TD () ;Test Delete

(setq selA(ssget)) ;get base selection A
(setq selB(ssget)) ;get selection B to remove from selection C
(setq selC selA)   ;copies selection A and removes selection B to return the difference
(setq selD selA)   ;extra variable to test how ssdel works

(setq i 0) ;index
(repeat (sslength selB) ;repeat for each entity in selB
   (ssdel (ssname selB i) selC) ;intended to remove selB from selC. It is also removeing selB from selA, which I don't want.
   (setq i (1+ i))) ;increment
)

;Functions below are used to test which geometry is contained in which selection set
(defun c:dela () ;delete geometry in selection A
(If(/= nil selA)(command ".erase" selA "")(princ "\n selA is empty. Run TD to initialize"))(princ)) ;if selA contains entities, delete them. If not, display error. 

(defun c:delb () ;delete geometry in selection B
(If(/= nil selB)(command ".erase" selB "")(princ "\n selB is empty. Run TD to initialize"))(princ)) ;if selB contains entities, delete them. If not, display error. 

(defun c:delc () ;delete geometry in selection C
(If(/= nil selC)(command ".erase" selC "")(princ "\n selC is empty. Run TD to initialize"))(princ)) ;if selC contains entities, delete them. If not, display error. 

(defun c:deld () ;delete geometry in selection d
(If(/= nil selD)(command ".erase" selD "")(princ "\n selD is empty. Run TD to initialize"))(princ)) ;if selD contains entities, delete them. If not, display error. 

Link to comment
Share on other sites

This does not copy the PICKSET,

 

(setq selC selA)  

 

It simply makes another pointer to the original selection set

 

Command: sq

Variable Name:   ss1

Variable Value:   (ssget)

Select objects: Other corner: 3 found

Select objects:  <Selection set: 701>

Command: sq

Variable Name:   ss2

Variable Value:   (ssget)

Select objects: c
First corner: Other corner: 2 found

Select objects: c
First corner: Other corner: 1 found

Select objects:  <Selection set: 702>

Command: (setq ss3 ss1)
<Selection set: 701>

Command: (sslength ss3)
3

Command: (ssdel (ssname ss1 0) ss3)
<Selection set: 701>

Command: (sslength ss1)
2

Command: !SS3
<Selection set: 701>

Command: !SS1
<Selection set: 701>

 

 

See how everything refers back to selection set 701 in this example

 

-David

Link to comment
Share on other sites

Thank you! I'm going to do research on the matter. If you have suggestions on how to modify the routine to work how I want, that would rock, but I think I now have enough information to search out the answer. I greatly appreciate how quickly you answered. Thanks :)

Link to comment
Share on other sites

To copy a a PICKESET :

 

(defun css (ss / rs i en)
(setq rs (ssadd)
(setq i 0)
(while (setq en (ssname ss i))
      (ssadd en rs)
      (setq i (1+i)))
rs)

 

(setq ss2 (css ss1))

Written on the fly - Untested

 

-David

Link to comment
Share on other sites

Thank you both! It was taking longer to figure out than I expected. It's working perfectly now. I'm also glad to have both versions, as I can now use it in a wider variety of routines. I do have Express Tools installed, so I'm good there. For future reference of anybody who might want it, the final solution implemented in my code is as follows:

 

(defun c:TD () ;Test Delete

(setq selA (ssget)) ;get base selection A
(setq selB (ssget)) ;get selection B to remove from selection C
(setq selC (acet-ss-union (list selA))) ;creates a new selection set and copies selection A

(setq i 0) ;index
(repeat (sslength selB) ;repeat for each entity in selB
   (ssdel (ssname selB i) selC) ;removes selB from selC
   (setq i	(1+ i))) ;increment
)

;Functions below are used to test which geometry is contained in which selection set
(defun c:dela () ;delete geometry in selection A
(If(/= nil selA)(command ".erase" selA "")(princ "\n selA is empty. Run TD to initialize"))(princ)) ;if selA contains entities, delete them. If not, display error. 

(defun c:delb () ;delete geometry in selection B
(If(/= nil selB)(command ".erase" selB "")(princ "\n selB is empty. Run TD to initialize"))(princ)) ;if selB contains entities, delete them. If not, display error. 

(defun c:delc () ;delete geometry in selection C
(If(/= nil selC)(command ".erase" selC "")(princ "\n selC is empty. Run TD to initialize"))(princ)) ;if selC contains entities, delete them. If not, display error. 

Edited by benhubel
Corrected a comment in the code
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...