试试俺的程序,支持加减乘除和开方,使用很简单,选择文本直接输入 +2 ,即可全部增加2,小数位在格式里设置 ;;文本计算器 (defun C:tadd ( / sa k ss str yusf n shzi h hh) (princ "\n 选择所有文字:") (setq ss (ssget '((0 . "text"))) str (getstring "\n 输入四则运算及数值:") yusf (substr str 1 1) shzi (atof (substr str 2)) n (sslength ss) k 0 ) (while (< k n) (setq names (ssname ss k) sa (entget names) h (assoc '1 sa) hh (atof(cdr h))) (if (= yusf "+")(setq str1 (rtos (+ hh shzi) 2))) (if (= yusf "-")(setq str1 (rtos (- hh shzi) 2))) (if (= yusf "*")(setq str1 (rtos (* hh shzi) 2))) (if (= yusf "/")(setq str1 (rtos (/ hh shzi) 2))) (if (= yusf "^")(setq str1 (rtos (expt hh shzi) 2))) (setq h1 (cons 1 str1)) (setq sa (subst h1 h sa)) (entmod sa) (setq k (+ k 1)) )(princ) ) |