Results 1 to 10 of 13

Thread: Help write a routine that will inverse a selection

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    2005-12
    Posts
    17
    Login to Give a bone
    0

    Default Help write a routine that will inverse a selection

    I am a novice when it comes to LISP and I have been trying to find someone willing to help me write a routine that will inverse a selection. I don't want to come waltzing onto a board and demand help, but what the heck...

    Anywho....
    What I have been trying to write is a LISP that will allow me to take a selection that I currently have - selection window over that - selecting everything around my current selection - then DE-selecting what I had in the selection.

    Make sense?

    I have gotten some help on other boards, but most of the routines were written to be used during a command. That's not what I want at all.

    I am selecting objects (picking or quick select) then modifying the selection in the properties box (layer management typically) then wanting everything that I don't currently have in my selection in exchange.

    I have some routines if you'd like me to post them, but I m afraid of posting them and confusing the issue....


    Thanks in advance.

  2. #2
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Help write a routine that will inverse a selection

    Something like this?
    Code:
    (defun c: xss (/ ss1 ss2 idx);;;;;remove the space after the c:
      (setvar "cmdecho" 1)
      (setq ss1 (ssget "I"))
      (sssetfirst nil nil)
      (if (setq ss2 (ssget))
        (progn
          (if ss1
    	(progn
    	  (setq idx 0)
    	  (repeat (sslength ss1)
    	    (ssdel (ssname ss1 idx) ss2)
    	    (setq idx (1+ idx))
    	    )
    	  )
    	)
          )
        )
      (sssetfirst ss2 ss2)
      (princ)
      )

  3. #3
    Member
    Join Date
    2005-12
    Posts
    17
    Login to Give a bone
    0

    Default Re: Help write a routine that will inverse a selection

    I tried that, it calles for the ss command to be used inside another command. Unless I'm doing something wrong.....

    This is the same kind of routine I have been working on basically. But the trouble is I want to use this LISP as a command by itself. I want to:

    1. Make my selection - then modify it as needed (through the properties box)
    2. Invoke the LISP command at the command prompt ("ss" for example)
    3. Window over (what will be) a new selection set - which are objects in VERY close proximity to my current selection.
    4. Select all objects I have windowed over - discarding(deselecting) my previous/current selection in exchange for the new selection.
    5. Modify new selection via properties....

    I just wish I understood the LISP language, then I could do this without help. Sorry to be a pain in the neck, I do appreciate the effort.

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Help write a routine that will inverse a selection

    Quote Originally Posted by brandi_eyes53
    I tried . . . .
    you do not need a lisp, try standard command options R P like this :
    1. make a selection
    2. do things
    3. make a new selection
    4. type R for remove ( read the command prompt ) and P for previous.

    : ) Happy Computing !

    kennet

  5. #5
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Help write a routine that will inverse a selection

    brandi_eyes53
    If you could explain this statement:
    Quote Originally Posted by Broman
    Here http://cadtutor.net/forum/viewtopic.php?t=4927
    "When I load these routines most of them are calling for the LISP to be invoked inside a command. That doesn't help me. Are LISP routines required to be inside another command?"
    Perhaps we could understand what problem you are having.

  6. #6
    Member
    Join Date
    2005-12
    Posts
    17
    Login to Give a bone
    0

    Default Re: Help write a routine that will inverse a selection

    Quote Originally Posted by kennet.sjoberg
    you do not need a lisp, try standard command options R P like this :
    1. make a selection
    2. do things
    3. make a new selection
    4. type R for remove ( read the command prompt ) and P for previous.

    : ) Happy Computing !

    kennet

    Thanks for the tip, but I have already tried that and it doesn't work. I lose the functionality of the properties box after removing the selection. I can't slide all of the (new) objects into a single layer and place the line attributes as I'd like them...They show up as changed while I am in there, but after I hit enter and go back and click on any of the lines I have (apparently) changed - they haven't changed at all. If I go back and select previous from ther they may (sometimes) show the changes as a grouped selection, but the individual objects are unchanged.


    And as for the LISPs I still haven't found one on any message board anywhere that will do what I want......I guess this one is a real stumper. So now is probably a bad time to tell you abou tthe other one I'd like to see.......

  7. #7
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Help write a routine that will inverse a selection

    At long last I think I see what you want.
    Try this one.
    Code:
    ;;  CAB  01/06/06 
    (defun c:ss- (/ ss_exclude ss ss_keep) 
      (defun ss->lst (ss / i ename result) 
        (and ss ; must test for nil 
             (setq i -1) 
             (while (setq ename (ssname ss (setq i (1+ i)))) 
               (setq result (cons ename result)) 
             ) 
        ) 
        result 
      ) 
      (if (or (setq ss_exclude (cadr (ssgetfirst))) 
              (setq ss_exclude (ssget "P"))) 
        (progn 
          (sssetfirst nil) ; clear the selection set 
          (prompt "nSelect all items to be considered.") 
          (setq ss      (ssget) 
                ss_keep (ssadd) 
          ) 
          (and ss ; must test for nil 
               (setq ss_list (ss->lst ss_exclude)) 
               (setq i -1) 
               (while (setq ename (ssname ss (setq i (1+ i)))) 
                 (if (not (member ename ss_list)) 
                   (progn 
                     (ssadd ename ss_keep) 
                   ) 
                 ) 
               ) 
          ) 
          (if (and ss_keep (> (sslength ss_keep) 0)) 
            (progn 
              (sssetfirst ss_keep ss_keep) 
              (prompt "nSelection set created use Previous to use.") 
            ) 
          ) 
        ) ; progn 
        (prompt "n***  ERROR, you must select items to exclude first.") 
      ) 
      (princ) 
    ) 
    (prompt "nSelection set subtract loaded, Enter ss- to run.") 
    (princ)

Similar Threads

  1. Replies: 9
    Last Post: 2007-10-23, 12:34 PM
  2. Replies: 52
    Last Post: 2007-09-27, 09:09 PM
  3. Replies: 7
    Last Post: 2006-08-18, 08:15 AM
  4. Write a LISP routine to enhance the revcloud command
    By melissa.j.seidel in forum AutoLISP
    Replies: 7
    Last Post: 2005-11-14, 06:08 PM
  5. Please HELP: Need "Inverse of a Matrix" routine
    By bradipos in forum AutoLISP
    Replies: 0
    Last Post: 2005-07-08, 02:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •