Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

No problem, I thought you might be talking about a selection set :)

 

Thanks for clearing that up :)

 

Lee

Posted

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

Posted

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

Posted

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
)

Posted

Ahhhh! ssmemb! Completely forgot about that function! :oops::oops::oops:

Posted

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.

Posted

Anytime you're mass deleting objects without verification it's considered dangerous.

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