AutoLISP将多段线各个端点坐标写入外部文件
2011-03-29 17:17 精诚所至 金石为开 阅读(947) 评论(0) 编辑 收藏 举报AutoLISP将多段线各个端点坐标写入外部文件,代码如下。
(defun c:test()
(setvar "cmdecho" 0)
(setq ffn (getfiled "选取文件" "" "doc" 1))
(setq ff (open ffn "w"))
(close ff)
(princ "\n选取多段线:")
(setq ss (ssget))
(setq i 0)
(setvar "pdmode" 33)
(repeat (sslength ss)
(setq ssn (ssname ss i))
(setq endata (entget ssn))
(setq n 0)
(repeat (length endata)
(setq pp (nth n endata))
(setq key (car pp))
(if (= key 10)
(progn
(setq x (cadr pp))
(setq y (cadr pp))
(command "point" (list x y))
(setq ff (open ffn "a"))
(princ x ff)
(princ " " ff)
(princ y ff)
(princ "\n" ff)
(close ff)
)
)
(setq n (1+ n))
)
(setq ff (open ffn "a"))
(princ "End\n" ff)
(close ff)
(setq i (1+ i))
)
(princ (strcat "\n文件写至=" ffn))
(prin1)
)
代码完。