我认为ReMark的referal赢了:D 如果没有,这应该有效(假设2D):
(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 44) 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)))
那样的话,我就拿一杯啤酒作为奖品。非常感谢你。 我附上了我的一些坐标
请检查一下
谢谢
__________________________
对不起我的英语
如果你不想使用备注法,可以把坐标复制到一个文本文件中,告诉我是什么把它们分开的,是制表符、空格还是逗号。 这是空间
X和Y
135643 4740
135650 4737
135656 4734 好的,如果从文本文件的顶部删除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)))
你能告诉我要做什么吗?
谢谢
____________________________
对不起我的英语
关于加载例程:
http://www.cadtutor.net/faq/questions/28/How+do+I+use+an+AutoLISP+routine%3F
加载后,在ACAD中用“ptpoly”调用它。
选择文本文件,工作就完成了(希望如此!)
页:
1
[2]