BIIST 发表于 2022-7-6 08:48:40

数字生成器

大家好
 
我得到了一个例程,可以为顺序编号的文本输入前缀,该例程使用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.
;;;www.mossdesigns.com, August 2001
;;;
;;;
;;;Michael E. Beall
;;;michael.beall@autocadtrainerguy.com
;;;www.autocadtrainerguy.com, 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
(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
)                                        ;end while
(princ)
)                                        ; end defun
(prompt "\nType WSNUM to run. ")


 
我在那里迷路了伙计们,欢迎任何帮助
 
提前感谢

SLW210 发表于 2022-7-6 09:04:42

请阅读代码发布指南并编辑您的帖子。
 
我已经将此移到AutoLISP、Visual LISP和DCL论坛。

Lee Mac 发表于 2022-7-6 09:12:42

我建议在这里找到我的编号程序,但这只允许文本的一部分递增。

BIIST 发表于 2022-7-6 09:31:53

嘿,李
我用了你的一些剧本。。。非常有用,它节省了我很多时间。。。非常感谢。
 
你的剧本看起来不错。。。更多选项:是的,稍后再试。。。但我需要知道是否有任何可能允许文本的2-3-4部分递增
 
提前感谢

Lee Mac 发表于 2022-7-6 09:43:52

再靠近一点,这将增加字符串的多个部分,但目前仅增加1。
 
这给了我一个新的想法,为我的网站申请。。。一个程序如何提示选择文本/多行文字,并询问要增加哪些节(具有选择多个节的选项),然后要求增加。然后,用户可以连续放置选定对象的副本,增加选定的部分。

BIIST 发表于 2022-7-6 09:57:30

 
好主意。。。这正是我想要的
页: [1]
查看完整版本: 数字生成器