I am trying to create a function wherein it would ask a user to select a text (either TEXT/MTEXT) then it would simply alert the value of that TEXT/MTEXT's color, layer, contents, and height which are stated in the properties.
I have this code but an error of "Program ERROR: bad argument type: stringp nil"
(defun c:selecttext()
(setq textobj (car (entsel "\nSelect text or mtext: ")))
(if (and textobj (member (cdr (assoc 0 (entget textobj))) '("TEXT" "MTEXT")))
(progn
(setq textinfo (entget textobj))
(setq textvalue (cdr (assoc 1 textinfo)))
(setq textheight (cdr (assoc 40 textinfo)))
(setq textcolor (cdr (assoc 62 textinfo)))
(setq textlayer (cdr (assoc 8 textinfo)))
(alert (strcat "Text contents: " textvalue "\nHeight: " (rtos textheight) "\nColor: " textcolor "\nLayer: " textlayer)))
(alert "Please select a valid text or mtext object."))
(princ))