马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [FONT=courier new]
- (princ "\ntadd====txt add 文字序号增值 -----------lxx.2001.7")
- (defun c:tadd ()
- (princ "\ntadd====txt add 文字序号增值-----------lxx.2001.7")
- (setq ss (ssget '((0 . "TEXT")))
- nadd (getint "\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)
- )
-
-
-
-
- [/FONT]
|