发个dwg我看看
已经放上来了,麻烦你帮忙看看
(defun c:TTT ()
(setq ss (ssget '((0 . "INSERT")))) ; 选择所有的块
(if ss
(progn
(setq count-alist nil); 初始化编号计数的关联列表
(setq sslen (sslength ss))
(setq i 0)
(while (< i sslen)
(setq ent (ssname ss i))
(setq entdata (entget ent))
(setq attribs (entnext ent))
;(princ "\nBlock Reference Data:\n")
;(princ (cdr (assoc 2 entdata))) ;; 显示块名
(while (= (cdr (assoc 0 (entget attribs))) "ATTRIB")
(setq attribdata (entget attribs))
(if (= (cdr (assoc 2 attribdata)) "编号")
(progn
(setq num (cdr (assoc 1 attribdata)))
(setq existing-pair (assoc num count-alist))
(if existing-pair
(setq count-alist (subst (cons num (+ 1 (cdr existing-pair)))
existing-pair
count-alist))
(setq count-alist (cons (cons num 1) count-alist))
)
)
)
(setq attribs (entnext attribs))
)
(setq i (+ i 1))
)
(princ "\nCount of '编号' Values:\n")
(foreach item count-alist
(princ (strcat (car item) ": " (itoa (cdr item)) "\n"))) ; 输出所有编号及其出现次数
)
(princ "\nNo attribute blocks selected.")
)
(princ)
)
moshouhot 发表于 2024-5-18 01:29
谢谢了:handshake
页:
1
[2]