Importare testi in un file autocad

Questo programma serve ad importare da un file ordianto dei testi in un file autocad, dove per file ordinato si intende un file di testo creato con il programma corrispondente TXT2FILE.

;; Define the function (the program).
(defun c:FILE2TXT ( / FN1 FL1 HNDL-IN I TXTSTR-IN ENT OLDCE OLDERR OLDTE)
  ;; Save the current value of cmdecho then redefine it.
  (setq OLDCE (getvar "cmdecho"))
  (setvar "cmdecho" 1)
  ;; Save the current value of texteval then set it to 1
  (setq OLDTE (getvar "texteval"))
  (setvar "texteval" 1)
  ;; Save the current value of the error handling subroutine then redefine it.
  (setq OLDERR *error*)
  (defun *error* (errmes)
    (princ (strcat "\nExecution of FILE2TXT halted by the following error: " ERRMES))
    (setvar "cmdecho" OLDCE)
    (setq *error* OLDERR)
    (prin1)
  )
  ;;(setq *error* nil)
  ;; NOTE: to turn error handling off, erase the semicolon in the line above.
  ;; GET a FILE from the user and store it in FN1.
  (setq FN1 (getfiled "File to read" "textout.txt" "" 12))
  ;; OPEN file FN1 for reading as FL1.
  (setq FL1 (open FN1 "r"))
  ;; BEGIN LOOP loop1.
  ;; LOOP by STEPPING THROUGH the LINES of the FILE FL1, storing them in HNDL-IN.
  (setq I -1)
  (while (setq HNDL-IN (read-line FL1))
    (setq I (1+ I))
    ;; READ a line from file FL1 storing it in TXTSTR-IN.
    (setq TXTSTR-IN (read-line FL1))
    ;; OPERATION - store the result in ENT. 
    (setq ENT (HANDENT HNDL-IN))
    ;; MODIFY the code 1 value (Text string)  of the entity ENT.
    (if (assoc 1 (entget ENT))
      (entmod (subst (cons 1 TXTSTR-IN) (assoc 1 (entget ENT)) (entget ENT)))
      (entmod (cons (cons 1 TXTSTR-IN) (entget ENT)))
    )
  ) ;; END LOOP loop1.
  ;; CLOSE file FL1.
  (close FL1)
  ;; Reset "cmdecho" to previous value.
  (setvar "cmdecho" OLDCE)
  ;; Reset "texteval" to previous value.
  (setvar "texteval" OLDTE)
  ;; Reset *error* to previous definition.
  (setq *error* OLDERR)
  ;; Exit quietly (no return value.)
  (prin1)
)
Compago