本帖最后由 highflybird 于 2011-12-23 17:11 编辑
楼主是不是这个意思?
- (vl-load-com)
- (defun c:test (/ ss n ent obj txt)
- (if (setq ss (ssget '((0 . "*TEXT") (1 . "*%%128*,*%%129*,*%%130*,*%%131*,*%%133*"))))
- (repeat (setq n (sslength ss))
- (setq ent (ssname ss (setq n (1- n))))
- (setq obj (vlax-ename->vla-object ent))
- (setq txt (vla-get-textstring obj))
- (cond
- ((wcmatch txt "*%%128*")
- (setq txt (ReplaceText "%%129" "%%128" txt))
- )
- ((wcmatch txt "*%%129*")
- (setq txt (ReplaceText "%%130" "%%129" txt))
- )
- ((wcmatch txt "*%%130*")
- (setq txt (ReplaceText "%%131" "%%130" txt))
- )
- ((wcmatch txt "*%%131*")
- (setq txt (ReplaceText "%%132" "%%131" txt))
- )
- ((wcmatch txt "*%%133*")
- (setq txt (ReplaceText "%%132" "%%133" txt))
- )
- )
- (vla-put-textstring obj txt)
- )
- )
- (princ)
- )
- (defun ReplaceText (NewStr oldstr string / txt)
- (setq txt string)
- (while (vl-string-search oldstr txt)
- (setq txt (VL-STRING-SUBST NewStr oldstr txt))
- )
- txt
- )
|