DKT Posted January 17, 2011 Posted January 17, 2011 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 Quote
Lee Mac Posted January 17, 2011 Posted January 17, 2011 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) ) Quote
irneb Posted January 18, 2011 Posted January 18, 2011 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) ) Quote
Lee Mac Posted January 18, 2011 Posted January 18, 2011 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: Quote
Lee Mac Posted January 18, 2011 Posted January 18, 2011 Similarly with yours: (defun c:EraseInverse ( / ss ) (if (setq ss (ssget)) (command "_.ERASE" "_All" "_Remove" ss "")) (princ) ) Quote
irneb Posted January 18, 2011 Posted January 18, 2011 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! Quote
Lee Mac Posted January 18, 2011 Posted January 18, 2011 I understand it that ssget will allow an implied selection by default, but will only permit an implied selection if the "_I" mode is used. You're welcome Irne 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.