面积与长度测量函数出错
本帖最后由 nyistjz 于 2021-5-26 12:55 编辑大神帮忙看一下,我这个面积与长度的测量小程序为什么不能正常运行。
感谢!
[*](defun c:tt(/ ss);长度面积统计
[*](vl-load-com)
[*](setq ss (ssget '((0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE,ARC,LINE"))))
[*](setq l (sslength ss) i 0 totalarea 0 totlength 0)
[*](repeat l
[*] (setq ename (ssname ss i))
[*] (setq obj (vlax-ename->vla-object ename))
[*] (setq totalarea (vla-get-area obj))
[*] (setq totlength (vla-get-length obj))
[*] (princ "\n****默认绘图比例1:1,以mm为单位****")
[*] (setq n (sslength ss))
[*] (princ (strcat "\n>>>>>共统计了" (itoa n) "个"))
[*] (setq totlength (strcat ",总长度=" (rtos (/ totlength 1e3) 2 3) "m"))
[*] (setq totalarea (strcat ",总面积=" (rtos (/ totalarea 1e6) 2 3) "m2"))
[*])
[*](princ(strcat totlength totalarea))
[*](princ)
[*])
;直线段就没有area属性,圆弧就没有length属性,却有ArcLength属性
(defun c:tt(/ ss);长度面积统计
(vl-load-com)
(setq ss (ssget '((0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE,ARC,LINE"))))
(setq n (sslength ss)i 0totalarea 0 totlength 0)
(repeat n
(setq ename (ssname ss i))
(setq obj (vlax-ename->vla-object ename))
(setq dis (vlax-curve-getDistAtParam obj (vlax-curve-getEndParam obj)))
(setq totlength (+ dis totlength))
(setq area (vl-catch-all-apply 'vlax-curve-getArea (list obj)))
(setq i (1+ i))
(princ (strcat "\n第" (itoa i) "个图元, 长度=" (rtos dis 2 3)"mm"))
(if (/= area 0.0)
(progn
(setq totalarea (+ area totalarea))
(princ (strcat ", 面积=" (rtos area 2 3) "mm2"))
)
(princ (strcat ", 无面积属性!"))
)
)
(princ "\n****默认绘图比例1:1,以mm为单位****")
(princ (strcat "\n>>>>>共统计了" (itoa n) "个"
",累计长度=" (rtos (/ totlength 1e3) 2 3) "m"
",累计面积=" (rtos (/ totalarea 1e6) 2 3) "m2"
)
)
(princ)
) yshf 发表于 2021-5-26 13:25
;直线段就没有area属性,圆弧就没有length属性,却有ArcLength属性
(defun c:tt(/ ss);长度面积统计
(v ...
我的天哪,牛逼!
谢谢您!!! 谢谢楼上的朋友了!收藏学习下! yshf 发表于 2021-5-26 13:25
;直线段就没有area属性,圆弧就没有length属性,却有ArcLength属性
(defun c:tt(/ ss);长度面积统计
(v ...
长度标示和累计标示,在CAD2020上,不能用上?
页:
[1]