第一次来论坛向各位学习中,并与大家共享一下:
(defun c:mj (/ a b c d m pt pt1 pt2)
(vl-load-com);加载所有的Active X函数
(setq m (getint "\n 请输入拐点数: "))
(setq pt1 (getpoint "\n 请输入第1个拐点坐标:"))
(setq pt pt1)
(setq a (1- m))
(setq d 2)
(repeat a
(princ "\n 请输入第")
(princ d)
(princ "个拐点坐标:")
(setq pt2 (getpoint))
(command "pline" pt1 pt2 "")
(setq d (+ d 1))
(setq pt1 pt2)
)
(command "pline" pt1 pt "")
(setq s1 (ssget "X"))
(command "pedit" (entlast) "j" s1 "" "")
(command "zoom" "w" (getvar "extmin") (getvar "extmax"))
(setq b (entlast))
(setq vlb (vlax-ename->vla-object b))
(setq c (vla-get-area vlb))
(princ "\n 面积为: ")
(princ c)
(princ "平方米")
(princ)
)
以上代码段已在CAD2000,2004,2008测试通过请放心使用
使用方法:在CAD中先加载程序,再在命令行上输入MJ。