When working with AutoCAD drawing software, it is sometimes necessary to insert paragraph text written in a text editor into the graphic and use AutoCAD's text editing commands to modify it; sometimes it is necessary to output the existing text in the graphic to a file. For processing with a text editor. AutoCAD does not directly provide commands for text insertion and text output. What should I do if I encounter such a problem? Of course, the OLE method of copying and pasting through the clipboard cannot achieve the above requirements. The method described below solves the problem of importing and exporting plain text between AutoCAD and a text editor.
1. Import text
Although there is no command to insert text in AutoCAD, text insertion can be achieved using the multi-line text editing command "Mtext". In the Mtext dialog box, there is an "ImportText..." command button. After clicking, the "Open" dialog box appears. Here you can select the ".txt" and ".rtf" files on the disk to insert, the inserted text. That is, you can use the "Ddedit" command to edit, pay attention to the size of the inserted file can not exceed 16KB, which is a fly in the ointment. It is worth mentioning that you can change the default text editor of "Mtext" to "Windows Notepad" or "Microsoft Word 2000". Select the "Preferences..." dialog box of the "Tools" menu, and change the "Text Editor Application" item in the "Text Editor, Dictionary, Font File Names" directory from "Internal" to the disk path of Notepad or Word 2000, for example :C:WindowsNotepad.exe. The same operation can also be achieved by setting the system variable "Mtexted".
2. Export text
If there is only a small amount of text to export, in the edit box of "Ddedit" or "Mtext", select the text to copy, and then paste it into the text editor. However, if there are a lot of scattered text in the drawing that needs to be exported, the above method is not suitable. The small program "ExpText.lsp" provided below can directly output the selected text to a text file through AutoCAD window selection.
;;; ExpText.lsp(defun c:EXT (/ flnm fn sn index ents ent txt)
(setq flnm (getstring " File name:"))
(setq fn (open flnm "w"))
(setq s (ssget))
(setq n (sslength s))
(setq index ( - n 1))
(setq ents (entget (ssname s index)))
(setq index ( - index 1))
(setq ent (assoc 0 ents))
(if ( = "TEXT" (cdr ent))
(setq txt (cdr (assoc 1 ents)))
(write-line txt fn)
(princ "text export: EXT")
After the program is created, load "ExpText.lsp" through the "Appload" command, type EXT Enter after "Command:", enter the file name (with path and suffix name), and select the window (automatically filter non-text entities). The text entities that are output to the file at this time will be wrapped in the order they were created in the AutoCAD entity set and the carriage return.
Hasp Lock Out,Abs Insulation Padlock,Insulation Hasp Lock
Hi-Stay Trading Co., Ltd. , http://www.szprotection.com