cad如何计算不同圆的数量(lisp) AutuCAD中四个不同直径的圆,怎么用lisp计算出来
展开全部
(defun c:cr()
(princ "\n选择要进行统计的圆对象")
(setq ss (ssget (list (cons 0 "CIRCLE"))))
(setq pt (getpoint "\n选择输出基点:"))
(setq si 0 tx 65 px (car pt) py (cadr pt) li '() lii 0)
(setq os (getvar "osmode") om (getvar "cmdecho"))
(command "osmode" 0 "osmode" 0 "_.ucs" "w")
(repeat (sslength ss)
(setq cs (ssname ss si) ce (entget cs))
(setq cp (cdr (assoc 10 ce)))
(setq cr (cdr (assoc 40 ce)))
(if (setq lst (assoc cr li))
(setq ct (nth 1 lst) li (subst (list cr ct (1+ (nth 2 lst))) lst li))
(setq ct tx tx (1+ tx) li (cons (list cr ct 1) li))
)
(command "_.text" (polar cp (/ pi 2) (- cr 2)) 3 0 (chr ct))
(command "_.chprop" "l" "" "p" "c" 6 "")
(setq si (1+ si))
)
(foreach l li
(setq cp (list px (+ py (* lii 5))) )
(setq cr (nth 0 l) ct (nth 1 l) cn (nth 2 l))
(command "_.text" cp 3 0 (strcat (chr ct) ":" (itoa cn) "-%%C" (rtos (* cr 2) 2))2)
(command "_.chprop" "l" "" "p" "c" 6 "")
(setq lii (1+ lii))
)
(setvar "osmode" os)
(setvar "cmdecho" om)
(princ "\n统计完成!")
(princ)
)
(princ "\n选择要进行统计的圆对象")
(setq ss (ssget (list (cons 0 "CIRCLE"))))
(setq pt (getpoint "\n选择输出基点:"))
(setq si 0 tx 65 px (car pt) py (cadr pt) li '() lii 0)
(setq os (getvar "osmode") om (getvar "cmdecho"))
(command "osmode" 0 "osmode" 0 "_.ucs" "w")
(repeat (sslength ss)
(setq cs (ssname ss si) ce (entget cs))
(setq cp (cdr (assoc 10 ce)))
(setq cr (cdr (assoc 40 ce)))
(if (setq lst (assoc cr li))
(setq ct (nth 1 lst) li (subst (list cr ct (1+ (nth 2 lst))) lst li))
(setq ct tx tx (1+ tx) li (cons (list cr ct 1) li))
)
(command "_.text" (polar cp (/ pi 2) (- cr 2)) 3 0 (chr ct))
(command "_.chprop" "l" "" "p" "c" 6 "")
(setq si (1+ si))
)
(foreach l li
(setq cp (list px (+ py (* lii 5))) )
(setq cr (nth 0 l) ct (nth 1 l) cn (nth 2 l))
(command "_.text" cp 3 0 (strcat (chr ct) ":" (itoa cn) "-%%C" (rtos (* cr 2) 2))2)
(command "_.chprop" "l" "" "p" "c" 6 "")
(setq lii (1+ lii))
)
(setvar "osmode" os)
(setvar "cmdecho" om)
(princ "\n统计完成!")
(princ)
)
追问
谢谢cam0668 的回答,是想要的,在问一下,如果里面有很多沉孔,或怎么区别呢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我想四个和一个是一样的,举个例子
(sslength
(ssget "x" '((0 . "CIRCLE") (40 . 50)))
)
返回的是图纸中半径是50的圆的个数
(sslength
(ssget "x" '((0 . "CIRCLE") (40 . 50)))
)
返回的是图纸中半径是50的圆的个数
追问
在一张图中,有N个圆,圆的直径很多,,我的意思是分类标出有多少个圆,及直径,有点像,比较分析了,(ssget "x" '((0 . "CIRCLE") (40 . 50)))这只是提取50的圆,一个一个这样很累的。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询