对不起,我之前发布的代码有问题,因为我把它从一个更大的lisp例程中去掉了。这是ASMI的独立版本。
- ;; ============================================================ ;;
- ;; ;;
- ;; RENUM.LSP - This program converts TEXT, MTEXT and ;;
- ;; ATTRIBUTES in numbers with a prefix and ;;
- ;; a suffix. ;;
- ;; ;;
- ;; ============================================================ ;;
- ;; ;;
- ;; Command(s) to call: RENUM ;;
- ;; ;;
- ;; Specify a suffix, a prefix and starting number (for erase ;;
- ;; the old suffix or prefix you should press Spacebar). Pick ;;
- ;; to TEXT, MTEXT, ATTRIBUTES or press Esc to quit. The ;;
- ;; program remembers old properties and it is possible to ;;
- ;; confirm it pressing of Spacebar key. ;;
- ;; ;;
- ;; ============================================================ ;;
- ;; ;;
- ;; THIS PROGRAM AND PARTS OF IT MAY REPRODUCED BY ANY METHOD ;;
- ;; ON ANY MEDIUM FOR ANY REASON. YOU CAN USE OR MODIFY THIS ;;
- ;; PROGRAM OR PARTS OF IT ABSOLUTELY FREE. ;;
- ;; ;;
- ;; THIS PROGRAM PROVIDES THIS PROGRAM 'AS IS' WITH ALL FAULTS ;;
- ;; AND SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF ;;
- ;; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. ;;
- ;; ;;
- ;; ============================================================ ;;
- ;; ;;
- ;; V1.3, 12 May, 2005, Riga, Latvia ;;
- ;; © Aleksandr Smirnov (ASMI) ;;
- ;; For AutoCAD 2000 - 2008 (isn't tested in a next versions) ;;
- ;; ;;
- ;; [url]http://www.asmitools.com[/url] ;;
- ;; ;;
- ;; ============================================================ ;;
- (defun c:renum (/ oldPref oldSuf oldStart curText curStr)
- (vl-load-com)
- (if(not rnm:Pref)(setq rnm:Pref ""))
- (if(not rnm:Suf)(setq rnm:Suf ""))
- (if(not rnm:Start)(setq rnm:Start 1))
- (setq oldPref rnm:Pref
- oldSuf rnm:Suf
- oldStart rnm:Start); end setq
- (setq rnm:Pref
- (getstring T
- (strcat "\nPrefix: <"rnm:Pref">: ")))
- (if(= "" rnm:Pref)(setq rnm:Pref oldPref))
- (if(= " " rnm:Pref)(setq rnm:Pref ""))
- (setq rnm:Suf
- (getstring T
- (strcat "\nSuffix: <"rnm:Suf">: ")))
- (if(= "" rnm:Suf)(setq rnm:Suf oldSuf))
- (if(= " " rnm:Suf)(setq rnm:Suf ""))
- (setq rnm:Start
- (getint
- (strcat "\nStarting number <"
- (itoa rnm:Start)">: ")))
- (if(null rnm:Start)(setq rnm:Start oldStart))
- (while T
- (setq curStr(strcat rnm:Pref(itoa rnm:Start)rnm:Suf))
- (setq curText
- (car
- (nentsel
- "\n<<< Pick TEXT, MTEXT or ATTRIBUTE or press Esc to quit >>> ")))
- (if
- (and
- curText
- (member(cdr(assoc 0(entget curText)))
- '("TEXT" "MTEXT" "ATTRIB"))
- ); end and
- (progn
- (if
- (vl-catch-all-error-p
- (vl-catch-all-apply 'vla-put-TextString
- (list(vlax-ename->vla-object curText)curStr)))
- (princ "\n<!> Entity on locked layer <!>")
- (setq rnm:Start(1+ rnm:Start))
- ); end if
- ); end progn
- (princ "\n<!> This is not DText or MText <!>")
- ); end if
- ); end while
- (princ)
- ); end of c:renum
- (princ
- (strcat "\n*** Text, MText or Attributes"
- " numbering tool. Type RENUM to run.*** "))
-
-
查看ASMI的网站。http://www.asmitools.com |