帮助,关于txt选项,neede
好的,伙计们,谢谢你们在这里为我们服务。我是lisp的初学者,这是我的第一篇帖子。我正在尝试编写一个lisp,它将创建一个点的txt数字描述(+每个下一个点1个数字),并将其放置在用户定义的点上。当lisp为一个点创建一个文本时,我希望它是可见的,并固定在一个光标上,直到我单击它将被定位的位置。你能建议我如何用Lisp程序的语言写下来吗?提前谢谢你。
这是我的Lisp程序:
(defun c:descr (/ startNum inp rot)
(setq startNum (getint "\nInsert start number <1>: "))
(if (= startNum nil)(setq startNum 1))
(setq rot (getreal "\nInser txt rotation angle <0>: "))
(if (= rot nil)(setq rot 0))
(setq inp (getpoint "Specify first point: "))
(while inp
(command "text" inp 1.5 rot startNum)
(setq inp (getpoint "Specify next point: "))
(setq startNum (+ startNum 1))
)
(princ)
) 也许这会帮助你:
增量编号套件 谢谢李,这是我需要的东西,但我正在努力学习lisp,这个例程太复杂了,我找不到与文本跟随光标问题相关的这部分 如果你需要一个简单的代码
(defun c:descr (/ startNum inp rot)
(defun chg ()
(setq ent (entget (entlast)))
(entmod (subst (cons 1 (itoa (setq startNum (1+ startNum))))
(assoc 1 ent) ent )))
(setq startNum (getint "\nInsert start number <1>: "))
(if (= startNum nil)
(setq startNum 1)
)
(setq rot (getreal "\nInser txt rotation angle <0>: "))
(if (= rot nil)
(setq rot 0)
)
(setq inp (getpoint "Specify first point: "))
(command "text" inp 1.5 rot startNum)
(while (and (princ "\nPress Escape to terminate:")
(not (command "_copy" (entlast) "" inp pause (chg)))
(setq inp (getvar 'lastpoint))
))
(princ)
)
记住按ESC键终止命令。
如果用户按ESC以外的任何键终止程序,则可以修改上述代码段。
HTH公司 谢谢pBe这就是我需要的,但既然我是初学者,你能解释一下“while”标签中发生了什么吗。我设法理解了“defun chg”的功能。
再次感谢
在上述情况下,终止while表达式的唯一方法是按ESC键,而不是通过任何方式完全退出,这并不是使用while的理想方式。我正在考虑使用grread函数通过按任意键来终止循环,使用该函数肯定会为初学者打开一罐蠕虫。最好慢慢来。
while函数通常会对表达式求值,只要条件不为零,它就会保持在“循环”中
例子:
(while (setq object (Car (entsel "\nSelect Object: "))) ;<---- this line is the condition, will prompt you as long you keep selecting an entity
(princ (strcat "\nSelected object is a "
(cdr (assoc 0 (entget object)))
) ;_ end of strcat
) ;_ end of princ
) ;_ end of while
玩得开心-大卫 FWIW:利用grread的附加代码
(defun c:descr (/ sdef num rot inp)
(setq sdef
(if global_sdef global_sdef 1))
(initget 0)
(setq num (getint (strcat "\nStarting Number <" (itoa sdef)">: ")))
(or num (setq num sdef))
(setq global_sdef num)
(initget 0)
(setq rot (getangle "\nInsert Text Rotation Angle <0>: "))
(or rot (setq rot 0))
(while (setq inp (getpoint (strcat "\nPoint Number " (itoa num) " Location: ")))
;;;MAIN TEXT ENTITY VALUES
(entmake (list (cons 0 "TEXT")
(cons 1 (itoa num))
(cons 10 inp)
(cons 50 rot)
(cons 40 1.5)
;;;TEXT SCALE AND OBLIQUE ANGLE
(assoc 41 (tblsearch "STYLE" (getvar "TEXTSTYLE")))
(cons 51 (cdr (assoc 50 (tblsearch "STYLE" (getvar "TEXTSTYLE")))))
;;;TEXT JUSTIFICATIONS
(cons 11 (list 0 0 0))
(cons 71 0)
(cons 72 0)
(cons 73 0)
;;;CURRENT ENTITY CONSTURUCTION SETTINGS
(cons 7 (getvar "TEXTSTYLE"))
(cons 8 (getvar "CLAYER"))
(cons 6 (getvar "CELTYPE"))
(cons 39 (getvar "THICKNESS"))
(cons 62 (cond ((= (getvar "CECOLOR") "BYLAYER") 256)
((= (getvar "CECOLOR") "BYBLOCK") 0)
(T(atoi (getvar "CECOLOR")))))
(cons 210 (trans '(0 0 1) 0 1))))
(setq num (1+ num)))
(prin1))
不过有点乱。愉快地剖析代码的grread行
在此处了解grread:
http://www.cadtutor.net/forum/showthread.php?57304-Get-quot-alert-quot-when-pressing-a-key-in-a-while-loop-how&highlight=Wrap+statements+expression
祝大家新年快乐。 新年快乐
谢谢你们的回答伙计们
@pBe我理解这一部分,但接下来的几行都是我不理解的
对于grread函数,我需要更多的时间。如果你们不介意的话,我会问你们更多的问题
页:
[1]