AutoLISP自动计算封闭区域面积
2011-03-29 16:30 精诚所至 金石为开 阅读(1200) 评论(0) 编辑 收藏 举报AutoLISP自动计算封闭区域面积,代码如下。
(defun c:test()
(setvar "cmdecho" 0)
(setq pt (getpoint "\n选取点:"))
(while pt
(setvar "cecolor" "1")
(command "bpoly" pt "")
(setq en (entlast))
(if (/= en nil)
(progn
(command "area" "o" en)
(setq aa (getvar "area"))
(redraw en 3)
(alert (strcat "面积=" (rtos aa 2)))
)
)
(entdel en)
(setvar "cecolor" "bylayer")
(setq pt (getpoint "\n选取点:"))
)
(prin1)
)
代码完。
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)