Thread Content
(defun c:outt() (setq ffn(getfiled \"Write file\" \"\" \"text\" 1)) (setq ss(entsel \"\n Select text\") (setq ff(open ffn \"w\")) (setq ssdata(entget(car ss))) (setq txt (cdr (assoc 3 ssdata))) (prin1 txt ff) (close ff) (prin (strcat \"\n File written to: \" ffn)) (prin1) )
(setq ss(entsel "\n Select text")) This function is not as good as using the ssget function. (setq txt (cdr (assoc 3 ssdata))) Should this group code be 1? :(setq txt (cdr (assoc 1 ssdata)))
2# fl202, will you give it a try by yourself?
I gave it a try; why don’t you give it a try yourself? My result is: the content of the file is: nil
Indeed, it returns NIL. Here is a piece of code I wrote for reference: ;******************************************Importing CAD text into an Excel spreadsheet (defun c:123() (setq ffn (getfiled \"Select file\" \"\" \"xls\" 1)); Using XLS here will result in an Excel file being exported, TXT will result in a text file being exported, and DOC will result in a WORD file being exported… Use it as you see fit! ! ! (princ "\nSelect text...") (setq ss (ssget)) (setq ff (open ffn "w")) (setq i 0) (repeat (sslength ss) (setq ssn (ssname ss i)) (setq ssdata (entget ssn)) (setq sstyp (cdr (assoc 0 ssdata))) (if (or (= sstyp "TEXT") (= sstyp "MTEXT")) (progn (setq txt (cdr (assoc 1 ssdata))) (princ txt ff) (princ "\n" ff) ) ) (setq i (1+ i)) ) (close ff) (princ (strcat "\nFile written to: " ffn)) (prin1) )