vladthedog Posted March 4, 2009 Posted March 4, 2009 I'm working on a lisp and I'm needing to inverse what was selected by the user. meaning, if the file has A-Z, and the user has A and Z selected, the code would unselect A and Z, and select B-Y. Thanks. Quote
vladthedog Posted March 4, 2009 Author Posted March 4, 2009 You lost me there. Let me explain what I will be using it for: I just mean, in model space, working on a drawing that has a lot of stuff on it, i'd like to be able to select the one thing i need, have it reverse the selection and delete all the stuff I don't need. I'm just trying to practice my lisp creation process, so I was asking the minimal help type of question. Sorry for the confusion. Quote
Lee Mac Posted March 4, 2009 Posted March 4, 2009 No problem, I thought you might be talking about a selection set Thanks for clearing that up Lee Quote
Lee Mac Posted March 4, 2009 Posted March 4, 2009 I've got this, but it only seems to work on the first use... not sure why? (defun c:test (/ ss i eLst invss) (setq ss (ssget) i (sslength ss) eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) invss (ssget "X" (list (cons 410 (getvar "CTAB"))))) (while (not (minusp (setq i (1- i)))) (if (member (cdar (entget (ssname invss i))) eLst) (ssdel (ssname invss i) invss))) (sssetfirst nil invss) (princ)) Quote
David Bethel Posted March 4, 2009 Posted March 4, 2009 Quite dangerous, but here ya go! [b][color=BLACK]([/color][/b]defun c:danger [b][color=FUCHSIA]([/color][/b]/ ss[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not ss[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect Entities To Save..."[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq ss [b][color=NAVY]([/color][/b]ssget[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.ERASE"[/color] [color=#2f4f4f]"_All"[/color] [color=#2f4f4f]"_Remove"[/color] ss [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote
CAB Posted March 5, 2009 Posted March 5, 2009 Here is a subroutine. ;; CAB 03.05.09 ;; Subtract ss2 from ss1 & return a selection set ;; ss1 & ss2 must be valid selection sets (defun ssSubtract (ss1 ss2 / ss3 idx ent) (setq ss3 ss1 idx (sslength ss2) ) (while (> (setq idx (1- idx)) -1) (setq ent (ssname ss2 idx)) (if (ssmemb ent ss3) (ssdel ent ss3)) ) ss3 ) Quote
Lee Mac Posted March 5, 2009 Posted March 5, 2009 Ahhhh! ssmemb! Completely forgot about that function! :oops: Quote
vladthedog Posted March 5, 2009 Author Posted March 5, 2009 Thanks guys. I haven't had a chance to test the various codes you've all put up, but i should be good to go. And David, I can see why you would say it's dangerous, but it's for programming our cnc's. the original file is locked so they can't save it anyway, and all they do is delete the stuff they don't need and place it on the table drawing. Quote
ABuckingham Posted March 5, 2009 Posted March 5, 2009 Anytime you're mass deleting objects without verification it's considered dangerous. 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.