这是对原文的改写(但仍然是笛卡尔式的):
- (defun c:bdimp (/ StrBrk mk_pt mk_txt FILE LST NL PT)
- (vl-load-com)
- (defun StrBrk (str chrc / pos lst)
- (while (setq pos (vl-string-position chrc str))
- (setq lst (cons (substr str 1 pos) lst)
- str (substr str (+ pos 4)))) ;;Mod
- (reverse (cons str lst)))
-
- (defun mk_pt (p) (entmake (list '(0 . "POINT") '(8 . "COORD") (cons 10 p))))
-
- (defun mk_txt (pt val)
- (entmake (list (cons 0 "TEXT")
- (cons 8 "POINT NUMBER")
- (cons 10 pt)
- (cons 40 1.6)
- (cons 1 val))))
-
- (if (setq file (getfiled "Select Text File" (if *load$file* *load$file* "") "txt" 16))
- (progn
- (setq *load$file* file file (open file "r"))
-
- (while (setq nl (read-line file))
- (setq lst (cons (StrBrk nl 32) lst))) (close file)
-
- (foreach line lst
- (mk_pt (setq pt (mapcar 'distof (list (cadr line) (caddr line) "0"))))
- (mk_txt pt (car line)))))
-
- (princ))
|