@dexus Well done! This works very well!
Just a suggestion if you wish to add more to it. My code below is for incorporating Function keys during a grread loop would be a good addition. It doesn't support everything, like Snap, polar tracking, osnap tracking, but it does all the toggle modes. It can replace the return condition in your grread loop.
;|==============================================================================
Function Name: (pjk-Grread-Fkeys <Character Code))
Arguments:
kcode = integer; The Character code from the second element in the return from GRREAD.
Returns:
T if ENTER or SPACEBAR is pressed, otherwise NIL
Description:
This function emulates the functions performed when a function key is selected
within a GRREAD loop.
Created by Phil Kenewell 2018
================================================================================|;
(defun pjk-Grread-Fkeys (kcode / acv ret)
(setq acv (atof (substr (getvar "acadver") 1 4)))
(cond
((= kcode 6) ;; F3
;; Faster more efficient way to toggle osmode. Thanks to Lee Mac for the idea.
(princ
(strcat "\n<Osnap "
(if (>= (setvar "osmode" (boole 6 (getvar "osmode") 16384)) 16384) "off>" "on>")
)
)
)
((= kcode 25) ;; F4
(if (>= acv 18.1) ;; If AutoCAD 2011 or Higher
(princ
(strcat "\n<3DOsnap "
(if (= (logand (setvar "3dosmode" (boole 6 (getvar "3dosmode") 1)) 1) 1) "off>" "on>")
)
)
(princ
(strcat "\n<Tablet "
(if (= (setvar "tabmode" (- 1 (getvar "tabmode"))) 1) "on>" "off>")
)
)
)
)
((= kcode 5) ;; F5
(cond
((= (getvar "SNAPISOPAIR") 0)(setvar "SNAPISOPAIR" 1)(princ "\n<Isoplane Top>"))
((= (getvar "SNAPISOPAIR") 1)(setvar "SNAPISOPAIR" 2)(princ "\n<Isoplane Right>"))
((= (getvar "SNAPISOPAIR") 2)(setvar "SNAPISOPAIR" 0)(princ "\n<Isoplane Left>"))
)
)
((= kcode 4) ;; F6
(if (>= acv 17.0) ;; If AutoCAD 2007 or Higher
(princ
(strcat "\n<Dynamic UCS "
(if (= (setvar "ucsdetect" (- 1 (getvar "ucsdetect"))) 1) "on>" "off>")
)
)
(princ
(strcat "\n<Coords "
(if (= (setvar "coords" (if (= (getvar "coords") 2) 0 2)) 2) "on>" "off>")
)
)
)
)
((= kcode 7) ;; F7
(princ
(strcat "\n<Grid "
(if (= (setvar "gridmode" (- 1 (getvar "gridmode"))) 1) "on>" "off>")
)
)
)
((= kcode 15) ;; F8
(princ
(strcat "\n<Ortho "
(if (= (setvar "orthomode" (- 1 (getvar "orthomode"))) 1) "on>" "off>")
)
)
)
((= kcode 2) ;; F9
(princ
(strcat "\n<Snap "
(if (= (setvar "snapmode" (- 1 (getvar "snapmode"))) 1) "on>" "off>")
)
)
)
((= kcode 21) ;; F10
(princ
(strcat "\n<Polar "
(if (= (logand (setvar "autosnap" (boole 6 (getvar "autosnap") 8)) 8) 8) "on>" "off>")
)
)
(Princ "\nNOTE: Polar Tracking is not supported in this command.")
)
((= kcode 151) ;; F11
(princ
(strcat "\n<Object Snap Tracking "
(if (= (logand (setvar "autosnap" (boole 6 (getvar "autosnap") 16)) 16) 16) "on>" "off>")
)
)
(Princ "\nNOTE: Object Snap Tracking is not supported in this command.")
)
((= kcode 31) ;; F12
(if (>= acv 16.2) ;; If AutoCAD 2006 or Higher
(princ
(strcat "\n<Dynamic Input "
(if (minusp (setvar "dynmode" (- (getvar "dynmode")))) "off>" "on>")
)
)
)
)
((vl-position kcode '(13 32)) ;; Enter or Spacebar
(setq ret T)
)
)
ret
) ;; End Function (pjk-Grread-Fkeys)