I think I have settled on this:
(defun c:EraseEmptyText (/ selSet)
(startUndo)
(setq selSet (ssget "X"
'((-4 . "<OR")
(-4 . "<AND")
(0 . "*TEXT")
(-4 . "<OR")
(1 . "")
(1 . " ")
(1 . " ")
(-4 . "OR>")
(-4 . "AND>")
(-4 . "<AND")
(0 . "MTEXT")
(1 . "\\A1;")
(-4 . "AND>")
(-4 . "OR>")
)
)
)
(princ
(strcat
"\n"
(itoa
(cond
(selSet
(mapcar 'entdel (mapcar 'cadr (ssnamex selSet)))
(sslength selSet)
)
(T 0)
)
)
" blank text entities erased.\n"
)
)
(endUndo)
(princ)
)
The thing I don't like about it is, technically you could have a line of text that was nothing but 100 spaces, and this routine wouldn't pick it up. With the database iteration method, since you test each TextString value manually rather than filtering for specific ones, you can do a test like the following, but it's probably too expensive to justify.
(= 0
(length
(vl-remove-if
'(lambda (x)
(= x 32)
)
(vl-string->list txtVal)
)
)
)