;;;       ==================================
;;;       |　   统计图中所使用的钢筋种类   |
;;;       |        Update:2007-06-28       |
;;;       |           [涂墙之处]           |
;;;       |        [同是土木人论坛]        |
;;;       |      [它山之石图形工作室]      |
;;;       ==================================

;|
1、支持全选
2、支持交互选择
3、支持写出统计结果
4、支持不写出时在命令行显示
5、支持“TEXT”实体
6、支持所有图层
7、很无耻的不支持“MTEXT”、“BLOCK”、“XREF”等
8、支持所有CAD版本
9、准源码，欢迎转载，RP及口德不佳者无视
|;

(defun c:mini_GJZL (/ old_cmd dengji gangjin pt1 pt2 ss zhijing pt str x y )
	(mini_start nil)
	(mai_last_com "mini_GJZL")
	; (mai_get_scale)
	(setq
		dengji	'("%%130" "%%131" "%%132"  "%%133")
		zhijing	'("6" "8" "10" "12" "14" "16" "18" "20" "22" "25" "28" "32" "40" "50")
	)
	(if (setq pt1 (getpoint "\n统计图中钢筋种类,请点取选择范围的第一点：<全选>"))
		(setq pt2 (getcorner pt1 "\n统计图中钢筋种类,第二点：<退出>"))
	)
	(if (and pt1 (not pt2))
		(exit)
		(setq pt (getpoint "\n写入点：<退出>"))
	)
	; (setq hh (* mai_scale2 (cadddr maitextname)))
	(foreach x dengji
		(foreach y zhijing
			(setq
				gangjin (strcat x y)
				ss (list (cons 0 "TEXT") (cons 1 (strcat "*" gangjin "*")))
				ss (if (and pt1 pt2)
					(ssget "w" pt1 pt2 ss)
					(ssget "x" ss)
				)
			)
			(if ss
			   (setq str (cons (strcat gangjin (if (member y '("6" "8")) "   " "  ") (atoi (sslength ss))) str))
				; (progn
					; (setq str (strcat gangjin (if (member y '("6" "8")) "   " "  ") (rtos (sslength ss) 2 0)))
					; (if pt
						; (mai_draw_text nil (setq pt (polar pt (* pi 0.5) (* 1.2 hh))) hh 0 str (caddr maitextname) nil 0.8)
						; (princ (strcat "\n" str))
					; )
				; )
			)
		)
	)
	(setq ss (mai_dos_tempfile "txt"))
	(mai_write_file ss (reverse str))
	(mai_shell_ascii_edit ss nil)
	(mai_end)
)



