大家好
我得到了一个例程,可以为顺序编号的文本输入前缀,该例程使用Dtext例程将文本放置在当前文本样式的当前层上。
通常我用它来标记一根电线。。。例如:04.1,04.2,04.3。。。。其中“04”是perfix,起始数是1,增量数也是1
它的工作完美!!
现在我需要对其进行一些升级,以标记一些2/3/4线:
我的意思是这样的:
-2线:04.1/04.2,04.3/04.4,。。。
-3线:04.1/04.2/04.3,04.4/04.5/04.6,。。。
-4线:04.1/04.2/04.3/04.4,04.5/04.6/04.7/04.8,。。。
不幸的是,我的Lisp程序不太好,所以我说你可能可以帮我。
代码如下:
-
- ;;;This WSNUM.LSP routine enables you to enter a prefix for sequentially
- ;;;numbered text which uses the Dtext routine to place text on the current
- ;;;layer in the current text style.
- ;;;
- ;;;This file has been edited from the 'cabnum.lsp' routine
- ;;;originally created by Elise Moss of Moss Designs.
- ;;;[url]www.mossdesigns.com[/url], August 2001
- ;;;
- ;;;
- ;;;Michael E. Beall
- ;;;michael.beall@autocadtrainerguy.com
- ;;;[url]www.autocadtrainerguy.com[/url], January 2002
- ;;;502.633.3994 (voice + FAX)
- ;;;Modified 4 August 2o11 - accepts decimal numbers for text height input
- ;;; - accepts only whole numbers for all other input
- ;;; - error in incrementation corrected
- ;;; - general tidying up and reorganisation of code
- (defun c:wsnum ()
- ; get prefix
- (setq prefix (getstring "\nPrefix <04.>? "))
- (if (= prefix "")
- (setq prefix "04.")
- )
- ; get starting number
- (setq stnum (getint "\nStarting number <1>? "))
- (if (= stnum nil)
- (setq stnum 1)
- )
- ; get increment
- (setq incrnum (getint "\nIncrement numbers by <1>? "))
- (if (= incrnum nil)
- (setq incrnum 1)
- )
- ; get text height
- (setq txtht (getreal "\nSet text height to <1.4>: "))
- (if (= txtht nil)
- (setq txtht 1.0)
- )
- ; get insertion point
- (setq placepoint (getpoint "\nSelect text location: "))
- ; set placement string
- (setq label (strcat prefix "" (itoa stnum)))
-
- ; loop for all subsequent insertions, ESC or right click ends loop
- [color="red"] (while (/= placepoint nil)
- (setq label (strcat prefix " " (itoa stnum))) ; set placement string
- (command "text" placepoint txtht "0" label) ; place text
- (setq stnum (+ stnum incrnum)) ; increment number
- (setq placepoint (getpoint "\nSelect text location: ")) ; get next insertion point[/color]
- ) ;end while
- (princ)
- ) ; end defun
- (prompt "\nType WSNUM to run. ")
我在那里迷路了伙计们,欢迎任何帮助
提前感谢 |