@k005 wrote:
@hak_vz
" : " and " = " I won't enter it manually. The Lisp routine should be able to select this automatically... that's what I meant.
That way you can have any expression of type (description delimiter value unit) processed, but ok, here is the way you wish.
(defun c:total ( / *error* string_to_list ss total ent e i)
(defun *error* ( msg )
(if (not (member msg '("Function cancelled" "quit / exit abort")))
(princ)
)
)
(defun string_to_list ( str del / pos )
(if (setq pos (vl-string-search del str))
(cons (substr str 1 pos) (string_to_list (substr str (+ pos 1 (strlen del))) del))
(list str)
)
)
(princ "\nSelect text to add up > ")
(setq ss (ssget '((0 . "TEXT"))) i -1)
(setq total 0.0)
(cond
((and ss)
(while (< (setq i (1+ i)) (sslength ss))
(setq ent (entget(ssname ss i)))
(setq e (cdr (assoc 1 ent)))
(if (vl-string-position (ascii ":") e) (setq del ":")(setq del "="))
(setq e (cadr (string_to_list e del)))
(setq total (+ total (atof(cadr (string_to_list e " ")))))
)
)
)
(princ (strcat "\nTotal sum is " (rtos total 2 2)))
(princ)
)
Miljenko Hatlak

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.