AutoCAD LISP循环判断语句绘制多个圆内接正多边形
2011-03-27 00:14 精诚所至 金石为开 阅读(669) 评论(0) 编辑 收藏 举报AutoCAD LISP循环判断,根据输入的正多边形边数,语句绘制多个圆内接正多边形,代码如下。
(defun c:test()
(setq n (getint "请输入正多边形边数N:"))
(setq en (entsel "\n选取欲作内接多边形的圆:"))
(setq i 0)
(while en
(setq endata (entget (car en)))
(setq entype (cdr (assoc 0 endata)))
(if (= entype "CIRCLE")
(progn
(setq cenpt (cdr (assoc 10 endata)))
(setq rad (cdr (assoc 40 endata)))
(command "polygon" n cenpt "i" rad)
(setq i (+ 1 i))
)
(alert "该对象不是圆,请重新选取圆")
)
(setq en (entsel "\n选取下一个欲作内接正多边形的圆:"))
)
(princ (strcat "\n共绘制了" (itoa i) "圆内接正多边形"))
(prin1)
)
(prompt "\n<<test>>连续对多个圆绘制内接多边形")
(prin1)
代码完。
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)