框选统计圆数量程序改善
(defun c:S88 (/)
(setq st (car (entsel)))
(if (/= st nil)
(progn (setq a1 (entget st)
a2 (cdr (assoc 40 a1))
a3 (cdr (assoc 8 a1))
a4 (ssget "x" (list (cons 8 a3)(cons 40 a2)))
a5 (sslength a4)
a2 (* a2 2)
a2 (rtos a2)
a5 (itoa a5)
)
(alert(strcat "\n直径【"a2"】 共计:【"a5"】个"))
))
(princ)
)
以上程序只能单选统计圆的个数,如何修改才能实现框选各种圆对象并统计各种圆的个数,请高手指点迷津谢谢
;;
(defun c:YGS (/ AS D DD DNS FS GET GV K KS LEN NN S ST)
(princ "\n功能 [统计圆直径数量弹窗]")
(setq gv (getvar "dimzin"))
(setvar 'dimzin 8)
(if (setq get (ssget '((0 . "CIRCLE"))))
(progn
(setq Len (sslength get) k 1)
(repeat Len
(setq nn (ssname get (setq Len (1- Len)))
as (cdr (assoc 40 (entget nn)))
as (atof (rtos as 2 2))
)
(if (null (setq dd (assoc as Dns)))
(setq Dns (cons (list as k) Dns))
(setq Dns (subst (list as (1+ (cadr dd))) (assoc as Dns) Dns))
)
)
(foreach x Dns
(setq d (car x)
s (cadr x)
st (strcat "直径"
(rtos (* d 2) 2 2)
",数量"
(rtos s 2 2)
"\n"
)
ks (cons (list st) ks)
)
)
(setq fs (apply 'strcat (mapcar 'car ks)))
;(alert fs)
(setq po (getpoint "input point----:"))
(command "text" po "2" "" FS"")
;(setq wz1 (entlast))
;(command "DDEDIT" wz1 "" "")
)
)
(setvar 'dimzin gv)
(princ)
);
本帖最后由 琴剑江山_10184 于 2015-6-3 14:01 编辑
(defun c:tt (/ AS D DD DNS FS GET GV K KS LEN NN S ST)
(princ "\n功能 [统计圆直径数量弹窗]")
(setq gv (getvar "dimzin"))
(setvar 'dimzin 8)
(if (setq get (ssget '((0 . "CIRCLE"))))
(progn
(setq Len (sslength get) k 1)
(repeat Len
(setq nn (ssname get (setq Len (1- Len)))
as (cdr (assoc 40 (entget nn)))
as (atof (rtos as 2 2))
)
(if (null (setq dd (assoc as Dns)))
(setq Dns (cons (list as k) Dns))
(setq Dns (subst (list as (1+ (cadr dd))) (assoc as Dns) Dns))
)
)
(foreach x Dns
(setq d (car x)
s (cadr x)
st (strcat "直径"
(rtos (* d 2) 2 2)
",数量"
(rtos s 2 2)
"\n"
)
ks (cons (list st) ks)
)
)
(setq fs (apply 'strcat (mapcar 'car ks)))
(alert fs)
)
)
(setvar 'dimzin gv)
(princ)
) 琴剑江山_10184 发表于 2015-6-2 17:17 static/image/common/back.gif
谢谢您的修改 琴剑江山_10184 发表于 2015-6-2 17:17 static/image/common/back.gif
通过测试文档结果显示为如上图,显示的是没有汇总。
726613 发表于 2015-6-3 08:21 static/image/common/back.gif
通过测试文档结果显示为如上图,显示的是没有汇总。
小数点的问题,上面代码已更新
与燕秀有得一比! 谢谢各位,辛苦了 若可以把得到之信息轉出,或可讀取就更完美了....謝謝 谢谢分享。 谢谢分享!!!