Hope this would help you with your work ...
Code:
(defun c:TesT (/ *error* acdoc n ss p i sset v)
;; ==-- Tharwat 29. Sep. 2011 --==;;
(vl-load-com)
(defun *error* (msg)
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **"))
)
(princ)
)
(setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (and (setq n 0
ss (ssget '((0 . "ATTDEF")))
)
(setq p (getpoint "\n Specify Attributes text location :"))
)
(progn
(repeat (setq i (sslength ss))
(setq sset (ssname ss (setq i (1- i))))
(if
(not (eq (atof (setq v (cdr (assoc 2 (entget sset))))) 0.0))
(setq n (+ n (atoi v)))
)
)
(vla-StartUndoMark acdoc)
(if (not (eq n 0.0))
(entmakex (list '(0 . "TEXT")
(cons 40 (getvar 'textsize))
(cons 10 p)
(cons 1 (rtos n 2))
'(50 . 0.)
)
)
)
)
(princ)
)
(vla-EndUndoMark acdoc)
(princ)
)
Tharwat