好的,如果从文本文件的顶部删除X和Y,这应该可以工作:
- (defun c:ptpoly (/ doc spc file nl ptlst)
- (vl-load-com)
-
- (setq doc (vla-get-ActiveDocument
- (vlax-get-Acad-Object))
- spc (if (zerop (vla-get-activespace doc))
- (if (= (vla-get-mspace doc) :vlax-true)
- (vla-get-modelspace doc)
- (vla-get-paperspace doc))
- (vla-get-modelspace doc)))
-
- (if (setq file (getfiled "Select File" "" "txt" )
- (progn
- (setq file (open file "r"))
- (while (setq nl (read-line file))
- (setq ptlst (cons (StrBrk nl 32) ptlst)))
- (close file)
- (if ptlst
- (progn
- (setq ptlst
- (apply 'append
- (mapcar
- (function
- (lambda (x)
- (list (car x) (cadr x))))
- (reverse
- (mapcar
- (function
- (lambda (x)
- (mapcar 'distof x))) ptlst)))))
- (vla-addLightweightpolyline spc
- (vlax-make-variant
- (vlax-safearray-fill
- (vlax-make-safearray
- vlax-vbdouble
- (cons 0 (1- (length ptlst)))) ptlst))))
- (princ "\n<< No Points Found in File >>")))
- (princ "\n<< No File Selected >>"))
- (princ))
-
- (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 2))))
- (reverse (cons str lst)))
|