PDA

View Full Version : 2017 Autosum



tea lover
2017-03-08, 10:20 AM
Friends!
I have AutoCAD 2014. I calculate manually text digits.:? I use calculator. :cry:
Do you know method or plugin autosum text digits?:shock:

rkmcswain
2017-03-08, 12:21 PM
Are you saying that you have text numerals in AutoCAD, and you want to add them up?

Are they organized, like in a column, or are they scattered around in the drawing?

If the former, you could put them into a TABLE, then use a formula to add them up.

https://s1.postimg.org/4khahefjj/table_sum.png

If the latter, you could use a lisp file such as this one (http://cadtips.cadalyst.com/general-text/total-selected-numbers).

cadtag
2017-03-08, 12:23 PM
here's a short lisp routine i've been using for a couple of decades


(defun c:sum ( / ss cnt txt)
(princ "\nSelect numbers to sum: ")
(setq ss (ssget '((0 . "TEXT,MTEXT")) ))
(if ss
(progn
(setq cnt 0 sum 0)
(repeat (sslength ss)
(setq txt (cdr (assoc 1 (entget (ssname ss cnt)))))
(setq sum (+ sum (atof txt)))
(setq cnt (1+ cnt))
)
(princ (strcat "\nThe sum of " (itoa (sslength ss)) " items selected = "
(rtos sum)))
)
(princ "\nNothing selected")
);end if
(princ)
)

tea lover
2017-03-09, 10:38 AM
Thank you very much!
I loaded sum.lsp into AutoCAD. I used command _appload.
It works!

- - - Updated - - -

Thanks a lot!
I named lisp file as wwt.lsp.
Now I have two lisp files in my AutoCAD:
sum.lsp
wwt.lsp
I appreciate what you've done for me.