Just a slight technical note. Osmode of 199 would give Endpoint, Midpoint, Centre, Insertion, Perpendicular.
If you wanted Intersection instead of Insertion, Osmode would be 167.
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)
)