一个很简单的统计各种实体长度之和的小程序
编了一个很简单的统计各种实体长度之和的小程序,支持*POLYLINE,SPLINE,ARC,CIRCLE,LINE和ELLIPSE,统计完毕后在提示行给出统计数据,自动累加到以 M 为单位,适合做预算之类的需要统计长度之和。(defun c:lc ( / aa asum bs bz_error i num_i old_cmd olderr per psum s sel_num)
(defun bz_start ( / )
(setq old_cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(eval "(command \"_.undo\" \"_group\)")
(setq olderr *error* *error* bz_error)
)
(defun bz_end ( / )
(setq *error* olderr)
(command "_.undo" "end")
(setvar "cmdecho" old_cmd)
(princ)
)
(defun bz_error (/)
(if (not (member s '("console break" "Function cancelled" "quit / exit abort")))
(princ (strcat "\nError: " s))
)
(bz_end)
)
;;-------------------------------------Main START
(bz_start)
(setq psum 0.00
i 0
)
(princ "\n选取需计算长度之和的直线、多义线、曲线或圆实体:")
(SETQ bs (SSGET '((-4 . "<OR" )
(0 . "*POLYLINE")
(0 . "SPLINE") (0 . "ARC")
(0 . "CIRCLE")
(0 . "LINE")
(0 . "ELLIPSE")
(-4 . "OR>"))
)
)
(SETQ SEL_Num (sslength bs))
(repeat SEL_Num
(setq Num_i (ssname bs i))
(command "lengthen" Num_i"" )
(setq per (/ (getvar "perimeter") 1000.0)
psum (+ per psum)
i(+ 1 i)
)
)
(princ (strcat "\n共统计了 "
(itoa i)
" 个线、多义线、曲线或圆实体,长度累加为:"
(rtos psum 2 2)"M!"
)
)
(bz_end)
)
(princ "\n命令:LC , 长度之和自动统计程序!!! Design by Ahill ! Copyright@2007")
选择易+统计,好用好好用!
谢谢楼主分享,下载收藏学习下! 确实给力,下载收藏学习下! 如果不想累加到米为单位,可以把这一句
(setq per (/ (getvar "perimeter") 1000.0)
中的1000.0改为1.0就变回以毫米为单位了。 楼主无私奉献精神值得学习! 能不能以公式的或者列的形式写入cad 好用,一直在找 谢谢,学习一下……………… 确实给力,下载收藏学习下! 谢谢……………… 谢谢楼主分享!
页:
[1]
2