马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
我不是搞结构的,呵呵,这回是应一位同事要求做的lsp。

- [FONT=courier new]
- (princ "\n ttlsn----梁编号递增修改ss vb1.0--for结构------lxx.2001.11")
- ;;
- (defun c:ttlsn ( / n roop key ii ent)
- (princ "\nttlsn----梁编号递增修改v1.0---for结构------lxx.2001.11")
- (princ "\n!只针对前缀 kl xl 的梁编号txt!")
- (setq n (getint "\n起始编号<1>:")
- roop "true")
- (if (not n)(setq n 1))
- (while roop
- (initget "X C R ")
- (setq key (getstring "\nX-退出/C-编号重复/R-重设编号/<选择梁编号>:"))
- (cond
- ((or (= "x" key)(= "X" key))
- (setq roop nil)
- );<X-退出>
- ((or (= "C" key)(= "c" key))
- (setq n (1- n))
- (princ "\n当前编号:")(princ n)
- );C-序号重复
- ((or (= "R" key)(= "r" key))
- (princ "\n当前编号:")(princ n)
- (setq n (getint "\n重设当前序号为:"))
- )
- ((= "" key)
- (princ "\n当前编号:")(princ n)
- (while (setq ss (ssget '((0 . "TEXT")(-4 . "< OR")(1 . "XL*")(1 . "KL*")(-4 . "OR >")) ))
- (setq ii 0)
- (repeat (sslength ss)
- (setq ent (ssname ss ii)
- ii (1+ ii)
- )
- (chn)
- );end rep
- (princ "\n下一编号:")(princ (1+ n))
- (setq n (1+ n))
- );end while
- )
- );end cond
- );end while
- (princ)
- )
- ;;(chn)
- (defun chn ( / entl e1 str1 i str2 i2 str3)
- (setq entl (entget ent)
- e1 (cdr (assoc 1 entl))
- str1 (substr e1 1 2)
- )
- (if (= " " (substr e1 3 1))
- (setq i 3
- str1 (strcat str1 " ")
- )
- (setq i 2)
- )
- (setq str2 (substr e1 (1+ i))
- str2 (rtos (atoi str2) 2 0)
- i2 (strlen str2)
- str3 (substr e1 (+ i i2 1))
- e1 (strcat str1 (itoa n) str3)
- entl (subst (cons 1 e1) (assoc 1 entl) entl)
- )
- (entmod entl)
- )
-
- [/FONT]
|