Many thanks for the drawing, it was a big help. The problem was with the text width. It was picking up the width of the MTEXT text box, which I though I had accounted for. This should now work correctly. I was previously storing all the selected entities in a list to make deleting them easier. The lisp now checks any selected entity against the list. If you have already selected it a pop up alert will tell you it has already been selected. Hope this now works as you require.
(defun rh:em_txt ( pt txt lyr sty tht xsf)
(entmakex (list '(0 . "TEXT") '(100 . "AcDbEntity") '(100 . "AcDbText")
(cons 10 pt) (cons 1 txt) (if lyr (cons 8 lyr)) (if sty (cons 7 sty)) (if tht (cons 40 tht)) (if xsf (cons 41 xsf))
);end_list
);end_entmakex
);end_defun
(vl-load-com)
(defun c:t+ ( / *error* ent elst el num xsf tot nlst sel pt txt)
(defun *error* ( msg )
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nAn Error : " msg " occurred.")))
(princ)
);end_defun
(while (not tot)
(setq el (entget (setq ent (car (entsel "\Select First Text Number Entity : ")))))
(cond ( (wcmatch (cdr (assoc 0 el)) "*TEXT")
(cond ( (= (cdr (assoc 0 el)) "TEXT") (setq num (atof (getpropertyvalue ent "TextString")) xsf (cdr (assoc 41 el))))
(t (setq num (atof (getpropertyvalue ent "Text")) xsf 1.0))
);end_cond
(cond ( (zerop num) (setq num nil) (alert "Text Entity NOT a number")) (t (setq tot num)))
)
(t (alert "Not a Text Entity"))
);end_cond
(cond (num (setq nlst (cons ent nlst))))
);end_while
(while (setq sel (entsel "\nSelect Next Text Number Entity : "))
(setq elst (entget (setq ent (car sel))))
(cond ( (and (wcmatch (cdr (assoc 0 elst)) "*TEXT") (not (vl-position ent nlst)))
(cond ( (= (cdr (assoc 0 elst)) "TEXT") (setq num (atof (getpropertyvalue ent "TextString"))))
(t (setq num (atof (getpropertyvalue ent "Text"))))
);end_cond
(cond ( (zerop num) (setq num nil) (alert "Text Entity NOT a number")))
)
( (vl-position ent nlst) (alert "Already Selected"))
(t (alert "Not a Text Entity"))
);end_cond
(if num (setq tot (+ tot num) nlst (cons ent nlst) num nil))
);end_while
(cond (tot
(setq pt (getpoint "\nSelect Total Insertion Point : ")
txt (if (zerop (rem tot 1.0)) (rtos tot 2 0) (rtos tot 2 3))
);end_setq
(rh:em_txt pt txt (cdr (assoc 8 el)) (cdr (assoc 7 el)) (cdr (assoc 40 el)) xsf)
(if nlst (foreach o (mapcar 'vlax-ename->vla-object nlst) (vla-delete o)))
)
);end_cond
(princ)
);end_defun