贴两个以前写的.

- ;;---tval数字text/标高text改值工具————————lxx.2001.2m
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (DEFUN C:tval (/ aa s i ll entt e v nv nvs)
- (princ "\n数字text/标高text改值工具————————lxx.2001.2m")
- (setq aa (getdist "\n差值-可为负值:") s (ssget) i 0 )
- (if (null (setq d (getdist "\n小数点后-精度<3>:")))(setq d 3))
- (REPEAT (SSLENGTH S)
- (setq ll (ssname s i) entt (entget ll))
- (if (= "TEXT" (cdr (assoc 0 entt)))
- (progn
- (setq e (assoc 1 entt)
- v (atof (cdr e))
- nv (+ v aa)
- nvs(rtos nv 2 3)
- )
- (if (= 0.0 nv)(setq nvs (strcat "%%128" nvs)))
- (setq entt (subst (cons 1 nvs) e entt))
- (entmod entt)
- )
- )
- (SETQ I (+ 1 I))
- )
- (princ)
- )
- (princ "\n 数字text/标高text改值工具————tval——————lxx.2001.2m")(princ)

- (princ "\ntxta ====txt add 文字增值 -----------lxx.2002.4")
- (defun c:txta ()
- (princ "\ntxta====txt add 文字增值-----------lxx.2002.4")
- (setq ss (ssget '((0 . "TEXT")))
- nadd (getdist "\n增加值<1>:")
- dec (getint "\n精度<0>:")
- i 0)
- (if (not nadd)(setq nadd 1))
- (if (not dec)(setq dec 0))
- (repeat (sslength ss)
- (setq ent (ssname ss i)
- entl (entget ent)
- i (1+ i)
- )
- (txtadd entl nadd dec)
- )
- (princ)
- )
- ;;;;;txtadd
- (defun txtadd (entl nadd dec /)
- (setq bnam0 (cdr(assoc 1 entl)));;;old txt
- (princ "\n原字串:")(princ bnam0)
- ;;使得序号不重复
- (setq nlen (strlen bnam0)
- n1 1
- lastn nil)
- (while (and (/= 0 nlen)(member (substr bnam0 nlen 1) '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" ".")))
- (setq lastn (atof (substr bnam0 nlen n1));;字串尾序号
- nlen (1- nlen)
- n1 (1+ n1)
- )
- );;end while
- (if lastn;;;;;;;;确定新字串---尾序号累加nadd,无序号加nadd
- (progn (setq lastn (+ lastn nadd))
- (if (or (= 'INT (type (read bnam0))) (= 'REAL (type (read bnam0))));;当字串如"3"
- (setq bnam (rtos lastn 2 dec))
- (setq bnam (strcat (substr bnam0 1 nlen) (rtos lastn 2 dec)))
- )
- )
- (progn (setq lastn nadd) ;;else
- (if (or (= 'INT (type (read bnam0)))(= 'REAL (type (read bnam0))))
- (setq bnam (rtos lastn 2 dec))
- (setq bnam (strcat bnam0 (rtos lastn 2 dec)))
- )
- )
- );;end if
- (princ " 改为:")(princ bnam)
- (setq entl (subst (cons 1 bnam) (assoc 1 entl) entl))
- (entmod entl)(entupd ent)
- )
-
|