|
20铜板
(defun c:a();生成文本到程序中转换
(setq wenjian(open "c:/1.txt" "w"))
(setq j1(getpoint "请输入第一点"))
(setq j2(getpoint "请输入第二点"))
(setq s(ssget))
(setq m(ssname s 0))
(setq quantu(entget m))
(setq biao(assoc 10 quantu))
(setq zuobiao(cdr biao))
(setq zuobiaolist(list zuobiao))
(setq quantu(subst (list 11 11) biao quantu))
(while (/= nil biao)
(setq biao(assoc 10 quantu))
(setq zuobiao(cdr biao))
(setq quantu(subst (list 11 11) biao quantu))
(setq zuobiaolist(cons zuobiao zuobiaolist))
(setq biao(assoc 10 quantu))
);while
;***以上为得到初始坐标
;排序
(setq i 0)
(while (/= 0 (distance j1 (nth i zuobiaolist)))
(setq i(+ 1 i))
)
(if (= (length zuobiaolist) (+ i 1))
(setq i 0)
)
(if (/= 0 (distance j2 (nth (+ 1 i) zuobiaolist)));顺时针
(setq zuobiaolist(reverse zuobiaolist))
)
(setq i 0)
(while (/= 0 (distance j1 (nth i zuobiaolist)))
(setq i(+ 1 i))
)
(setq xinzuobiaolist(list))
(repeat (length zuobiaolist)
(setq jj(nth i zuobiaolist))
(setq xinzuobiaolist(cons jj xinzuobiaolist))
(setq i(+ 1 i))
(if (= (length zuobiaolist) i)
(setq i 0)
)
)
(setq xinzuobiaolist(reverse xinzuobiaolist))
;排序完成,
;以下为生成界制点
(setq i 0)
(setq k 1)
(repeat (length xinzuobiaolist)
(setq j(strcat "J" (itoa k)))
(setq zuobiaoy(rtos (nth 1 (nth i xinzuobiaolist)) 2 3))
(princ zuobiaoy wenjian)
(princ "," wenjian)
(setq zuobiaox(rtos (nth 0 (nth i xinzuobiaolist)) 2 3))
(princ zuobiaox wenjian)
(princ "," wenjian)
(write-line j wenjian)
(setq i(+ 1 i))
(setq k(+ 1 k))
)
(close wenjian)
|
|