As an alternative, this is what I've used for years. A simple layer toggle.
This example is for the TEXT layer. If the layer is OFF, it is turned ON. If the layer is ON, it is turned OFF.
(defun C:TOGGLETEXT (/ elist clr)
(setq elist (entget (tblobjname "LAYER" "TEXT"))
clr (assoc 62 elist)
)
(entmod (subst (cons 62 (- (cdr clr))) clr elist))
(princ)
)
If the layer you wish to toggle might not yet be in the drawing, a check for the layer can be performed first with this version, which includes a notification that the layer does not exist..
(defun C:TOGGLETEXT (/ elist clr)
(if (not (tblsearch "LAYER" "TEXT"))
(alert
(strcat " TEXT Layer"
"\n Does not exist on this drawing"
)
)
(progn
(setq elist (entget (tblobjname "LAYER" "TEXT"))
clr (assoc 62 elist)
)
(entmod (subst (cons 62 (- (cdr clr))) clr elist))
)
)
(princ)
)
Steve