本帖最后由 linshiyin2 于 2012-5-15 15:59 编辑
- (defun C:xgxh ( / be h h1 hh j k lx n names sa shzi ss str str1 tc xh ys yusf zg)
- (initget 1)
- (setq be (entsel "\n选取要修改的序号:")
- be (car be)
- be (entget be);获取数据
- lx (assoc '0 be);对象类型
- tc (assoc '8 be);所在图层
- xh (atof (cdr (assoc '1 be)));序号
- ys (assoc '62 be);颜色
- zg (assoc '40 be);字高
- )
- (if ys
- (setq ss (ssget "x" (list lx tc zg ys)))
- (setq ss (ssget "x" (list lx tc zg )))
- )
- (setq str (getstring "\n 输入四则运算及数值<默认+1>:"))
- (if (= str "")
- (setq str "+1")
- )
- (setq yusf (substr str 1 1)
- shzi (atof (substr str 2))
- n (sslength ss)
- k 0
- j 0)
- (while (< k n)
- (setq names (ssname ss k)
- sa (entget names)
- h (assoc '1 sa)
- hh (atof(cdr h));对象序号
- )
- (if (>= hh xh)
- (progn
- (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))
- (setq j (+ 1 j))
- (entmod sa)
- )
- )
- (setq k (+ k 1))
- )
- (print (strcat "修改文字数:" (itoa j)))
- (princ)
- )
|