将所有数据从Excel文件复制到记事本,并将其另存为(txt文件),然后尝试此代码。
注意:字符串的形式必须与您在第#6号帖子中介绍的相同
祝你好运
- (defun c:Test (/ filename openfile string pos lst p h)
- ;;; Tharwat 27. March . 2012 ;;;
- ;; form of the string must be as following ;
- ; "596 490554.848 2788544.836 - 0.700 75MM" ;
- ; 596 = Number inside the circle ;
- ; 490554.848 = x ;
- ; 2788544.836 = y ;
- ; - 0.700 = z ;
- ; 75MM = diameter of circle ;
-
- (if (setq filename (getfiled "Select txt file ..."
- (getvar 'dwgprefix)
- "txt"
- 8
- )
- )
- (progn
- (setq openfile (open filename "r"))
- (while
- (setq string (read-line openfile))
- (while string
- (if (setq pos (vl-string-search " " string))
- (progn
- (setq lst (cons (substr string 1 pos) lst))
- (setq string (substr string (+ pos 2)))
- )
- (progn
- (setq lst (cons string lst))
- (setq string nil)
- )
- )
- )
- (setq lst (reverse lst))
- (entmakex
- (list
- '(0 . "CIRCLE")
- (cons 10
- (setq p
- (list (read (nth 1 lst))
- (read (nth 2 lst))
- (read (strcat (nth 3 lst) (nth 4 lst)))
- )
- )
- )
- (cons 40
- (setq h (read (vl-string-right-trim "MM" (nth 5 lst))))
- )
- )
- )
- (entmakex (list '(0 . "TEXT")
- (cons 10 p)
- (cons 11 p)
- (cons 1 (car lst))
- (cons 40 (/ h 2.))
- (cons 7 (getvar 'textstyle))
- '(50 . 0.)
- '(71 . 0)
- '(72 . 1)
- '(73 . 2)
- '(210 0.0 0.0 1.0)
- )
- )
- (setq lst nil)
- )
- )
- (princ)
- )
- (princ)
- )
|