AutoLISP统计图形中某种图元的数量
2011-04-10 15:45 精诚所至 金石为开 阅读(750) 评论(0) 编辑 收藏 举报AutoLISP统计图形中某种图元的数量,以圆和直线为例,代码如下。
(defun c:ssnum ()
(setq ss (ssget))
(setq i 0
line_num 0
circle_num
0
)
(repeat (sslength ss)
(setq name (ssname ss i))
(cond
((= "LINE" (cdr (assoc 0 (entget name))))
(setq line_num (1+ line_num))
)
((= "CIRCLE" (cdr (assoc 0 (entget name))))
(setq circle_num (1+ circle_num))
)
)
(setq i (1+ i))
)
(print (strcat "line=" (itoa line_num)))
(print (strcat "circle=" (itoa circle_num)))
(princ)
)
代码完。