How to create a selection set by picking objects one by one and ending the select operation by spacebar

How to create a selection set by picking objects one by one and ending the select operation by spacebar

sollowyne
Enthusiast Enthusiast
454 Views
7 Replies
Message 1 of 8

How to create a selection set by picking objects one by one and ending the select operation by spacebar

sollowyne
Enthusiast
Enthusiast

Masters,

Now I want to create a selection sets using lisp in a complex drawing, but there is something  confusing me, using fence selection can not select all the objects i want, so is there any way to create a selection sets using both fence selection and picking the objects one by one? of course, the one by one selection should be ended by  pressing of the spacebar.

Any suggestions will  be appreciated.

@pendean 

@ВeekeeCZ

@Kent1Cooper  

@WeTanks 

 

0 Likes
Accepted solutions (2)
455 Views
7 Replies
Replies (7)
Message 2 of 8

sollowyne
Enthusiast
Enthusiast

may a "while" function be helpful?

0 Likes
Message 3 of 8

paullimapa
Mentor
Mentor
Accepted solution

this link is directly from Autodesk on selection methods

this link is from Lee Mac

in either case I don't see an option to do a selection for fence and picking an object one at a time.

you can either just do one or the other

or you leave no restrictions and then all options are available for selection

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 8

john.uhden
Mentor
Mentor

@sollowyne ,

The SELECT command can accomplish what you want, but if you prefer your own method, might I suggest something like:

(defun myselect (/ s ss n)
  (setq ss (ssadd)) ; sets up an empty selectionset to which additional 
  ;;entites can be added
  (while (setq s (ssget))
   (repeat (setq n (sslength s))
    (ssadd (ssname s (setq n (1- n))) ss)
   )
  )
  ss
)
      

There is no need to worry about selecting duplicate entities; if any is already in the selection set, an additional one will be ignored.

 

John F. Uhden

Message 5 of 8

sollowyne
Enthusiast
Enthusiast

My code is as below:

 

(defun c:make-ss ()
  (setvar 'cmdecho 0)
  
  ; (setq ss (ssget "X" '((-4 . "<AND")
  ;                       (-4 . "<AND") (0 . "INSERT") (2 . "Instrument*") (-4 . "AND>")
                        
  ;                       ;(-4 . "<AND") (0 . "INSERT") (2 . "InstrumentL") (-4 . "AND>")
  ;                       (-4 . "AND>")
  ;                      ) 
  ;          )
  ; )
  (setq pt1 (getpoint "\pick the left top corner: "))
  (setq ss (ssget "w"  pt1 (getcorner pt1 "\npick the right bottom corner: ")))
  (setq ss-length (sslength ss ))
  (princ (strcat "\nthe length of the selection sets is: " (itoa ss-length)))
  
  (progn
    (setq ss (ssadd (car (entsel "\nPick the next object or quit by hitting the spacebar: ")) ss ))
    (princ (strcat "\nthe length of the selection sets now is: " (itoa (sslength ss))))
  )
  
  (while T
    (setq ss (ssadd (car (entsel "\nPick the next object or quit by hitting the spacebar: ")) ss ))
    (princ (strcat "\nthe length of the selection sets now is: " (itoa (sslength ss))))
  )
  
)
(defun *error* (msg)
  (princ (strcat "\nthe final length of the selection sets is: " (itoa (sslength ss))))
)
(prin1)

 

the quesiton is how to add a filter to ssget "w" ? 

Maybe I could use while function when i extract the data from the seletion sets.

0 Likes
Message 6 of 8

sollowyne
Enthusiast
Enthusiast
Accepted solution

Wow, LEE is a real god, truely solved my question! thank you as well.

(defun c:make-ss ()
  (setvar 'cmdecho 0)
  
  (setq pt1 (getpoint "\pick the left top corner: "))
  (setq ss (ssget "_w"  pt1 (getcorner pt1 "\npick the right bottom corner: ") '((0 . "INSERT") (2 . "Instrument*"))))
  (setq ss-length (sslength ss ))
  (princ (strcat "\nthe length of the selection sets is: " (itoa ss-length)))
  
  (progn
    (setq ss (ssadd (car (entsel "\nPick the next object or quit by hitting the spacebar: ")) ss ))
    (princ (strcat "\nthe length of the selection sets now is: " (itoa (sslength ss))))
  )
  
  (while T
    (setq ss (ssadd (car (entsel "\nPick the next object or quit by hitting the spacebar: ")) ss ))
    (princ (strcat "\nthe length of the selection sets now is: " (itoa (sslength ss))))
  )
  
)
(defun *error* (msg)
  (princ (strcat "\nthe final length of the selection sets is: " (itoa (sslength ss))))
)
(prin1)
0 Likes
Message 7 of 8

paullimapa
Mentor
Mentor

glad to have helped...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

Select by "F" fence needs a variable set as a fence line can go through the gap in objects like dashed lines, or text. Now what was the variable searching madly for it. 

0 Likes