Jump to content

Delete inverse


DKT

Recommended Posts

I'm trying to write a part of my function that will delete everything except what is selected. I thought the bit below would work, but it doesn't seem to do the trick. My thought was to utilize the "select" command to keep stuff simple, since I'm not entirely sure how the ssget lisp function works.

 

If I manually run the code below, typing each command into the prompt (command being escape), then it works.... Help?

 

(defun C:testing ()(command "select" "" (command) "erase" "all" "remove" "previous" ""))

 

 

Thanks. DKT

Link to comment
Share on other sites

Maybe...

 

(defun c:EraseInverse ( / a b c e )

 (if (setq c -1 a (ssget "_X") b (ssget))
   (while (setq e (ssname a (setq c (1+ c)))) (or (ssmemb e b) (entdel e)))
 )
 (princ)
)

Link to comment
Share on other sites

Or ... not having to step through each item in the selection set, and works with selection prior to issuing the command:

(defun c:EraseInverse (/ ss)
 (if (or (and (setq ss (cadr (ssgetfirst))) (sssetfirst nil))
         (setq ss (ssget))
         )
   (command "_.ERASE" "_All" "_Remove" ss "")
 )
 (princ)
)

Link to comment
Share on other sites

Or ... not having to step through each item in the selection set, and works with selection prior to issuing the command

 

Good call, but mine should work with selection prior to issuing the command... :wink:

Link to comment
Share on other sites

Thanks, can't think why ssget wouldn't use implied selections without the "I" switch - or though the ssgetfirst call? That's how I understood the help file, but obviously it works this way as well ... oh well, now I know this too. Thanks Lee! :thumbsup:

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