- ;;;;;;**************************************框选数字结尾文本求和
- (defun c:qh(/ all endno aa bb cc wz tha tsum i)
- (if (null xzz) (setq xzz 0))
- (yy-emk-yb)
- (setq ALL (ssget(list (cons 0 "text"))))
- (if all (SETQ nn (SSLENGTH ALL)))
- (setq endno 0)
- (setq tsum 0 i 0)
- (WHILE (and (< endno nn) all)
- (setq aa (ssname all endno))
- (setq bb (entget aa))
- (setq zggg (cdr (assoc 40 bb)))
- (setq cc(cdr(assoc 1 bb)))
- (setq wz(rdata cc))
- (setq tha(substr cc (+ wz 1) ( - (strlen cc) wz -1)))
- (if (= tha "") (setq tha "0"))
- (setq tsum(+ tsum (atof tha)))
- (setq i(1+ i))
- (print (strcat (itoa i) ":文本 <" cc ">---数字 <" tha ">"))
- (setq endno (+ endno 1))
- )
- (print (strcat "共" (itoa i) "个文本,和=" (rtos tsum)))
- (setq rk (rtos tsum))
- (SETQ PO (getpoint "\n指定文本输出位置:"))
- (COMMAND "TEXT" PO zggg 0 rk)
- (print)
- )
- (defun yy-emk-yb nil
- (if (not (tblobjname "Style" "公司标准"))
- (entmake
- '((0 . "Style")(100 . "AcDbSymbolTableRecord")
- (100 . "AcDbTextStyleTableRecord")
- (2 . "公司标准")(70 . 0)(40 . 0)(41 . 0.8)(50 . 0)(71 . 0)
- (42 . 0)(3 . "hztxt_e.shx")(4 . "hztxt.shx"))
- )
- )
- (setvar "TextStyle" "公司标准")
- (princ)
- )
- ;;;
- (defun rdata(str / len i aa)
- (if (> (strlen str) 0)
- (progn
- (setq i (strlen str))
- (setq aa(substr str (strlen str) 1))
- (while (and (or (and (>= aa "0") (<= aa "9"))
- (= aa ".")
- )
- (>= i 1)
- )
- (setq i(1- i))
- (if (>= i 1) (setq aa(substr str i 1)))
- )
- )
- )
- (setq i i)
- )
|