![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
lisp 如何排序输出?
(write-lines1out)(setqnu110)(whilee(setqed(entgete))(setqnu1(+nu2))(setqnu2(+nu12))(s...
(write-line s1 out)
(setq nu 110)
(while e
(setq ed (entget e))
(setq nu1 (+ nu 2))
(setq nu2 (+ nu1 2))
(setq nu3 (+ nu2 2))
(setq nu4 (+ nu3 2))
(setq name (cdr (assoc 0 ed) ) )
(if (= name "LINE")
(progn
(setq xy1 (assoc 10 ed))
(setq x1 (nth 1 xy1))
(setq y1 (nth 2 xy1))
(setq xy2 (assoc 11 ed))
(setq x2 (nth 1 xy2))
(setq y2 (nth 2 xy2))
(setq s (strcat "G00" " X"(rtos x2 2 3) " Y" (rtos y2 2 3) " Z-14.0\n"
"G01" " X"(rtos x1 2 3)" Y" (rtos y1 2 3) " Z-2.00\n" "G01 Z0.00"))
(write-line s out)
)
)
(setq e (entnext e))
(setq nu (+ nu4 2 ))
) 展开
(setq nu 110)
(while e
(setq ed (entget e))
(setq nu1 (+ nu 2))
(setq nu2 (+ nu1 2))
(setq nu3 (+ nu2 2))
(setq nu4 (+ nu3 2))
(setq name (cdr (assoc 0 ed) ) )
(if (= name "LINE")
(progn
(setq xy1 (assoc 10 ed))
(setq x1 (nth 1 xy1))
(setq y1 (nth 2 xy1))
(setq xy2 (assoc 11 ed))
(setq x2 (nth 1 xy2))
(setq y2 (nth 2 xy2))
(setq s (strcat "G00" " X"(rtos x2 2 3) " Y" (rtos y2 2 3) " Z-14.0\n"
"G01" " X"(rtos x1 2 3)" Y" (rtos y1 2 3) " Z-2.00\n" "G01 Z0.00"))
(write-line s out)
)
)
(setq e (entnext e))
(setq nu (+ nu4 2 ))
) 展开
1个回答
2015-01-06 · 知道合伙人软件行家
关注
![](https://wyw-base.cdn.bcebos.com/pc-content/follow.gif)
展开全部
(setq ss '());建立一个表
(setq ss (cons (list JL p1) ss));把(距离及交点组成表)加入表
(setq ss (vl-sort ss (function (lambda (x y)(< (car x) (car y))))));;排序距离从小到大排序。体会排序方法,距离最短的会在前面。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询