你好
请尝试一下我刚刚写的这个程序,告诉我你是如何使用它的,如果你需要任何进一步的功能扩展;
- (defun c:IncAtts (/ *error* run st blk e at pre num v)
- ;; Tharwat. cadtutor ;;
- ;; Date:04.May.2016 ;;
- (defun *error* (msg)
- (if (and msg
- (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))
- )
- (princ (strcat "\nError: " msg))
- )
- (princ)
- )
- (setq run t)
- (while (not (setq *starting:number*
- (cond ((and (setq st
- (getstring
- (strcat
- "\nSpecify starting number after char: eg. [X-1] <"
- (if *starting:number*
- *starting:number*
- (setq *starting:number* "A-1")
- )
- ">: "
- )
- )
- )
- (eq st "")
- )
- *starting:number*
- )
- ((and (wcmatch st "*-#*")
- (numberp (+ 2 (vl-string-search "-" st)))
- )
- (setq *starting:number* st)
- )
- (t nil)
- )
- )
- )
- (princ "\nUncorrect string!. Try again")
- )
- (princ "\nSelect attributed block with Tag name <1>:")
- (while
- (and
- run
- (setq blk
- (car
- (entsel
- )
- )
- )
- (eq (cdr (assoc 0 (setq e (entget blk)))) "INSERT")
- (eq (cdr (assoc 66 e)) 1)
- (if (vl-some
- '(lambda (x)
- (and (eq (vla-get-tagstring x) "1")
- (setq at x)
- )
- )
- (vlax-invoke (vlax-ename->vla-object blk) 'getattributes)
- )
- at
- (progn
- (princ "\nAttributed Block doesn't have tag name <1> !")
- (setq run nil)
- )
- )
- )
- (vla-put-textstring
- at
- (setq pre (substr *starting:number*
- 1
- (1+ (vl-string-search "-" *starting:number*))
- )
- num (substr
- *starting:number*
- (+ 2 (vl-string-search "-" *starting:number*))
- )
- *starting:number* (strcat pre (itoa (1+ (atoi num))))
- v (strcat pre num)
- )
- )
- )
- (princ)
- )(vl-load-com)
|