- (defun c:txtsum(/ i lm-str2ch num ss str tha tsum)
- (defun lm-Str2ch (String / positioni YPOutString)
- (setq positioni -1 aiilst'() jci 0)
- (repeat (strlen string)
- (setq ascm(vl-string-elt string (setq positioni (+ positioni 1))))
- (if (or(< 47 ascm 58)(= ascm 45)(= ascm 46)(= ascm 32))
- (setq aiilst(append aiilst (list ascm)))
- (setq jci (1+ jci))
- )
- )
- (car(mapcar'vl-list->string(reverse (list aiilst))))
- )
- (setq ss (ssget '((0 . "text"))))
- (if ss
- (progn
- (setq num (sslength ss))
- (setq tsum 0 i 0)
- (while (< i num)
- (setq str(cdr(assoc 1 (entget (ssname ss i)))))
- (setq tha(lm-Str2ch str))
- (if (= tha "") (setq tha "0"))
- (setq tsum(+ tsum (atof tha)))
- (setq i(1+ i))
- (princ (strcat "\n" (itoa i) ":文本 <" str ">---数字 <" tha ">"))
- )
- (princ (strcat "\n共" (itoa i) "个文本,和=" (rtos tsum)))
- )
- )
- (princ)
- )
- (princ "\n文本数字求和(型如:钉23,钉23钉,钉23.12,-23.12,钉,多行文字先炸开,支持负数),命令:txtsum")
- (princ)
|