Author Topic: Distinguish between (ssget)+enter and (ssget)+empty selection?  (Read 7268 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Re: Distinguish between (ssget)+enter and (ssget)+empty selection?
« Reply #15 on: April 12, 2015, 05:07:50 AM »
Are you only allowing the user one chance to select the objects? As Owen mentioned.
(setq ss (ssget ":S"))
if so then this is valid (= (getvar "ERRNO") 52) for ENTER only without an attempted selection.

An attempted selection returns 0
So you could put this in a loop if you need more than one attempt  at a selection.

Thank you for this answer, it is helpful for me too!
I hope that this code is useful also for other:

Code: [Select]
(defun c:test (/ var snapcorr ss next)
  ;*************************************
  (setq var (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq snapcorr (getvar "OSMODE"))
  (setvar "OSMODE" 0)
  ;*************************************

  (princ "\nSelect: ")
  (setq ss (ssget ":S"))
  (setq next T)
  (while (= next T)
    (progn
      (if ss
        (if (= (sslength ss) 1)
          (progn
            (alert "I have selected only an object, then I continue again.")
            (setq ss (ssget ":S"))
          )
          (progn
            (alert "I have selected more object, then I continue again")
            (setq ss (ssget ":S"))
          )
        )
        (progn
          (if (/= (getvar "ERRNO") 52)
            (progn
              (alert "I don't have selected any objects, then I continue again")
              (setq ss (ssget ":S"))
            )
            (progn
              (alert "I have press Enter, then END")
              (setq next nil)
            )
          )
        )
      )
    )
  )   

  ;*************************************
  (setvar "OSMODE" snapcorr)
  (setvar "cmdecho" var)
  (princ)
  ;*************************************
)
« Last Edit: April 12, 2015, 05:31:46 AM by Lupo76 »