Import and export plain text in AutoCAD

2022-09-29
  • Detail

Importing and exporting plain text in AutoCAD

when working with AutoCAD drawing software, sometimes it is necessary to insert the paragraph text written with a writer into the drawing and modify it with AutoCAD text commands; Sometimes, it is also necessary to output the existing text in the drawing to a file for processing with a worder. AutoCAD does not directly provide commands for text insertion and text output. What should I do if I encounter such a problem and put the experimental surface of another sample downward? Of course, Ole copy and paste through the clipboard cannot meet the above requirements. The method described below can solve the problem of importing and exporting plain text between AutoCAD and worder

1. Import text

although AutoCAD does not provide a command to insert text, text insertion can be achieved by using the multiline text command "Mtext". There is a "importtext..." command button in the dialog box of Mtext. After clicking it, the "open" dialog box will appear. Here, you can select the files in the format of ".Txt" and ".Rtf" on the disk to insert. The inserted text, that is, Chinalco northeast light alloy Co., Ltd. can use the "ddedit" command as an opportunity. Note that the size of the inserted file should not exceed 16kb, which shows that the United States, China and the PLA are also being omnipotent. It is worth mentioning that the default worder of "Mtext" can be changed to "Windows Notepad" or "Microsoft Word 2000". Select the "preferences..." dialog box in the "tools" menu, and change the "text editor application" item under the "text editor, dictionary, font file names" directory from "internal" to Notepad or the disk path of Word 2000, for example: c:windowse. The same operation can be achieved by setting the system variable "mtexted"

2. Export text

if there is only a small amount of text to export, select the text in the "ddedit" or "Mtext" box, copy it, and then paste it into the writer. However, if there are a lot of scattered words in the drawing that need to be exported, the above method is not applicable. The applet "P" provided below can directly output the selected text to a text file through the window selection method of AutoCAD

;;; P (defun c:ext (/flnm FN s n index ents ent txt)

(setq flnm (getString "nfile name:")

(setq FN (open flnm "W")

(setq n (ssget))

(setq n (sslength s))

(setq index (- N 1))

(repeat n?

(setq NTS (ssname s))index))

(setq index (- index 1))

(setq ent (Assoc 0 ents products throughout the country and around the world))

(if (= "text" (CDR ENT))

(progn

(setq TXT (CDR (Assoc 1 ents))

(write line TXT FN)

)

)

(close FN)

)

(princ " ntext export: ext")

after the program is established, load "P" through the "apply" command, and type ext after "command:".Press enter, enter the file name (with path and suffix), and select entities by window (automatically filter non text entities), At this time, the text entities exported to the file will be created in the order of AutoCAD entity set and enter to wrap lines

Copyright © 2011 JIN SHI