核对系统图中配电箱或配电柜开关数量时特别有用。

;单行文本分类汇总
(defun count()
    (subtotal(getlist))
)

;多行文本分类汇总
(defun mcount()
    (subtotal(getlist))
)


;对表中的文本进行分类汇总
(defun subtotal(lt)
    (setq e (car lt))
    (if (/= e nil)
        (progn
        (setq lt1(vl-remove e lt))
        (setq len1 (length lt))
        (setq len2 (length lt1))
        (princ (strcat e "出现的次数为:\n"))
        (princ (- len1 len2))
        (princ "\n")
        (subtotal lt1)
        )    
    )
)
;返回多行文本集合表
(defun getlistm()
    (setq s
        (ssget (list (cons 0  "mtext")))
    )
    (setq sl
        (sslength s)
    )
    (setq st 0)
    (setq lt(list))
    (while (< st sl)
        (setq e(ssname s st))
        (setq st(1+ st))
        (setq txt
            (cdr (assoc 1 (entget e)))
        )
        (setq lt(cons txt lt))
    )
)

;返回单行文本集合表
(defun getlist()
    (setq s
        (ssget (list (cons 0  "text")))
    )
    (setq sl
        (sslength s)
    )
    (setq st 0)
    (setq lt(list))
    (while (< st sl)
        (setq e(ssname s st))
        (setq st(1+ st))
        (setq txt
            (cdr (assoc 1 (entget e)))
        )
        (setq lt(cons txt lt))
    )
)