FWIW, vl-filename-base should still perform as expected even if the filename in question contains periods, observe:
_$ (vl-filename-base "179062-0000018159-Fa. Martin.dwg")
"179062-0000018159-Fa. Martin"
Hence the code could be written:
(defun c:todo ( / d f )
(if (or (findfile (setq f (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".txt")))
(and (setq d (open f "w")) (not (close d)))
)
(startapp "write" (strcat "\"" f "\""))
)
(princ)
)