;;;Elise Moss ;;;Moss Designs ;;;April 2009 ;;this routine adds text and shows it in a dialog box (defun c:addtxt () (setq t-list nil) (setq ss nil) (vl-load-com) (prompt "\n Select items to add: ") (setq ss (ssget (list (cons -4 "") ) ; end list ) ; end ssget ) ; end setq (setq ss-count (sslength ss)) ;initiate counter (setq item 0) (while (< item ss-count) (setq ent1 (ssname ss item)) ; Gets the name of the first ; entity in sset. (setq ent-data (entget ent1)) ;;; get the data for the obj (setq ent-text (cdr (assoc 1 ent-data))) ; CHECK IF IT IS MTEXT (setq search-str (vl-string-search ";" ent-text 2)) (if (/= search-str nil) (progn (setq search-str (+ search-str 2)) ; if search-str /= nil then it is mtext ; concontenate the string to just the number (setq ent-text (substr ent-text search-str)) ; got to get rid of the closing} (setq search-str2 (vl-string-search "}" ent-text 2)) ; re-shorten (setq ent-text (substr ent-text 1 search-str2)) ) ; end progn ) ;end if ; convert text to number (setq ent-text (atof ent-text)) ;check if ent-text is a number ; start list of text items (if (/= ent-text 0.0) (setq t-list (append t-list (list ent-text))) ) ;end if (setq item (+ item 1)) ) ;end while ; time to add up the t-list items ; reinit item (setq item 0) (setq count (length t-list)) (setq tot (+ (nth item t-list) (nth (+ item 1) t-list))) (setq item (+ item 2)) (while (< item count) (setq tot (+ tot (nth item t-list))) (setq item (+ 1 item)) ) ; end while ; now convert the total back to text (setq tot (rtos tot 2 2)) (alert (strcat "The total is: " tot)) ) ;end defun