
- ;| [url]http://www.xdcad.net/forum/showthread.php?postid=1716822#post1716822[/url]
- 从含有K1的长字符串中提取其括号及括号内的字符如(2)
- 作为后缀加到其它对应的短字符串如K1后,使K1变成K1(2)
- |;
- (defun c:akpost ( / a ss i lst ss2 fi ent)
- (command ".undo" "be")
- (or (setq a (entsel "\nPlease Select a Text 请选择带括弧的文本<全选> :"))
- (setq ss (ssget "X" '((0 . "TEXT")(1 . "K*(*)*")))))
- (setq i -1)
- (if a
- (setq lst (list (getpost (car a))))
- (mapcar '(lambda (x)
- (if (not (member (setq xx (getpost x)) lst))
- (setq lst (cons xx lst))
- )
- )
- (ss2lst ss)
- )
- )
- (mapcar '(lambda(x / ss2 fi)
- (setq fi (list (cons 0 "TEXT")(cons 1 (strcat "K" (car x)))))
- (if a
- (progn
- (princ "\nSelect Text(s) That You Want to Change 请选择要更改的文本<全选> :")
- (or (setq ss2 (ssget fi))
- (setq ss2 (ssget "x" fi))
- )
- )
- (setq ss2 (ssget "x" fi))
- )
- (if ss2
- (mapcar
- '(lambda (y / ent)
- (setq ent (entget y))
- (entmod
- (subst (cons 1 (strcat (cdr (assoc 1 ent)) (cadr x)))
- (assoc 1 ent)
- ent
- )
- )
- )
- (ss2lst ss2)
- ) )
- )
- lst
- )
- (command ".undo" "e")
- (princ)
- )
- ;; ss2lst.
- (defun ss2lst (sset / i e elst)
- (setq i -1)
- (while (setq e (ssname sset (setq i (1+ i))))
- (setq elst (cons e elst))
- );(reverse lst)
- )
- ;; getpost. (getpost (setq e (car(entsel))))
- (defun getpost (e / ent str n)
- (setq ent(entget e)
- str(substr (cdr(assoc 1 ent)) 2 ))
- (list(substr str 1 (setq n (vl-string-position (ascii "(") str)))
- (substr str (1+ n) (vl-string-position (ascii ")") str)))
- )
|