HCBBS Forum (English)
Submit Chemical Projects / Find Solutions
Amplify Your Requirements on a Broader Chemical Platform *Engineering · Technology · Equipment · Solutions*
Submit Request

Write a file

2009-08-05View Original

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) )
Reply #22009-08-05
(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)))
Reply #32009-08-05
2# fl202, will you give it a try by yourself?
Reply #42009-08-05
I gave it a try; why don’t you give it a try yourself? My result is: the content of the file is: nil
Reply #52009-08-05
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) )

Submit a Project

**Looking for Chemical Technology, Equipment & Solutions?** No Registration Required Broader Platform Exposure | Global Chemical Service Provider Connections

Submit Request — Free Consultation

Disclaimer

This is an automated machine translation of the original thread. Some technical terms may have inaccuracies; the original text shall prevail. Click "View Original" at the top right to access the source page, which supports IP-based automatic real-time language translation. Please watch out for contact details and sales inducements to prevent fraud. All content and translations are for reference only, representing solely the poster's personal views. For enquiries, email service@hcbbs.com.