BIGAL 发表于 2022-7-5 16:50:52

尝试:
(defun c:dimm(/*error*dft dimsft elst ent oldlayr oldorth pt)(setq oldlayr(getvar“clayer”)(setq oldorth(getvar“orthomode”))(defun*error*(msg)(if oldlayr(setvar“clayer”oldlayr))(if oldorth(setvar“orthomode”oldorth))(if ent(entdel ent))(if(and msg(not(非(wcmatch(strcase msg)”*取消*、*退出*、*退出*、*中断*))(提示消息));(laychk\u s“dim”“5”“continuous”)(while(setq dft(getreal”\n输入管道长度,单位为mm:)(if(setq dimsft;可以为零。(cond(<1 dft 304)。”

tmelancon 发表于 2022-7-5 16:52:45

罗伊,我非常感谢你的意见!这真是太棒了!

tmelancon 发表于 2022-7-5 16:56:51

tmelancon 发表于 2022-7-5 17:00:08

I figured it out guys. I added this to my error handler. Seems to be what I needed. Thanks everyone for their help. Full code in Post #12 has been updated.
 

(and ENT (entdel ENT))

tmelancon 发表于 2022-7-5 17:04:00

Grrrrrrr.. Ok so after using it just now, I am noticing a problem, apparently I am writing this method wrong because if the user steps into the routine, enters a value, places the value, then chooses to esc to exit the routine, it always deletes the previously added entity. I will keep trying to figure it out when I have time today.
 
I want the routine to:
1. prompt for value
2. allow user to place value
3. loop if users wants to enter more
4. esc to exit cleanly, leaving previously entered values OR
5. if a user enters another value accidentally but no longer wants that value
6. hitting esc exits the routine then deletes the value that is currently on cursor (grread) waiting for placement- leaving the existing values the user just placed.

Roy_043 发表于 2022-7-5 17:07:31

Try:

(defun c:dimm (/ *error* dft dimsft elst ent oldlayr oldorth pt) (setq oldlayr (getvar "clayer")) (setq oldorth (getvar "orthomode")) (defun *error* (msg)   (if oldlayr   (setvar "clayer" oldlayr)   )   (if oldorth   (setvar "orthomode" oldorth)   )   (if ent   (entdel ent)   )   (if   (and       msg       (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*EXIT*,*BREAK*"))   )   (prompt msg)   ) ) ; (laychk_s "dim" "5" "continuous") (while (setq dft (getreal "\nEnter pipe length in mm: "))   (if   (setq dimsft ; Can be nil.       (cond         ((< 1 dft 304.         "

tmelancon 发表于 2022-7-5 17:12:28

Roy I do appreciate your input! This worked out fantastically!
页: 1 [2]
查看完整版本: 输入平面尺寸(MM)