修改文字内容,需要对文字内容分析,根据给出的条件,是修改【=】号后面的值。autolisp代码如下:
(defun c:tes ( / #k2 &kw1 ent)
(setvar "dimzin" 0)
(if (not #k1) (setq #k1 6) )
(if (setq #k2 (getreal (strcat "\n请输入增加百分比默认%:<" (rtos #k1) ">")))
(setq #k1 #k2) (setq #k2 #k1)
)
(setq #k2 (* 0.01 (+ 100.0 #k1)))
(princ "\n请选择要修改的文字,文字内容有【=】号")
(if (setq &kw1 (ssget '((0 . "TEXT") (1 . "*=*"))))
(progn
(while (setq ent (ssname &kw1 0))
(setq &kw1 (ssdel ent &kw1))
(x1811151 ent #k2)
);while
)
)
(princ)
)
;修改内容
(defun x1811151 (ent #k2 / #g #k2 a1 ent n ss ss1 tr tr1 tr2 tr3)
(setq #g (entget ent)
a1 (assoc 1 #g)
tr1 (cdr a1)
ss '("-" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" ".")
n (1+ (vl-string-search "=" tr1 0))
tr2 (substr tr1 1 n)
tr1 (substr tr1 (1+ n))
tr3 ""
ss1 '()
)
(while (/= tr1 "")
(setq tr (substr tr1 1 1))
(if (member tr ss)
(setq ss1 (cons tr ss1) tr1 (substr tr1 2))
(setq tr3 tr1 tr1 "")
)
)
(if (car ss1)
(progn
(setq tr1 (rtos (* #k2 (read (apply 'strcat (reverse ss1)))) 2 2))
(setq tr1 (cons 1 (strcat tr2 tr1 tr3)))
(setq #g (subst tr1 a1 #g))
(entmod #g)
)
)
)
本回答被提问者和网友采纳