(defun c:test( / ss ent i ename da sum) (prompt "选择数据...") (setq ss (ssget '((0 . "text")))) (setq ent (car (entsel "选择结果..."))) (setq i 0 sum 0) (repeat (sslength ss) (setq ename (ssname ss i)) (setq da (atof (cdr (assoc 1 (entget ename))))) (if (/= da 0) (setq sum (+ sum da)) ) (setq i (1+ i)) ) (setq ent (entget ent)) (setq ent (subst (cons 1 (rtos sum)) (assoc 1 ent) ent)) (entmod ent) (princ) )