Re: Using grread on ESCAPE key to cancel a lisp function

#2
Hi,
Try to run the simple lisp:

Code: Select all

(defun c:test()
  (while ; stay in loop until one of the COND statements return nil
    (progn
      (setq input (vl-catch-all-apply 'grread (list T (+ 1 2 0))))
      (cond
	((vl-catch-all-error-p input)
	 (princ "\nPressed escape ")
	 nil ; exit
	 )
	((= 5 (car input)) ; pointing device
	 (cond
	   ((and LastPT (< (distance (cadr input) LastPT) 0.01))) ; no update if same point
	   ((setq ent (nentselp (setq LastPT (cadr input))))
	    (setq objName (cdr (assoc 0 (entget (car ent)))))
	    (princ (strcat "\nObject name: " objName))
	    )	   
	   )
	 t ; stay in loop
	 )
	)
      )
    ) ; while
   (princ)
   )