Costinbos77 发表于 2022-7-6 07:05:24

决策问题


 
如何根据暂停后给出的内容获得不同的结果:
选择点=true,或输入=nil?
 

(if (command "_move" (entlast) "" '(0 0 0) pause) a b)

GP_ 发表于 2022-7-6 07:10:40

正在等待其他答复。。。
 

(setq a (entget (entlast)))
(command "_move" (entlast) "" '(0 0 0) pause)
(if (equal a (entget (entlast))) (setq b 1) (setq b 2))

Lee Mac 发表于 2022-7-6 07:17:37

(defun c:test ( / s p )
   (if (and
         (setq s (ssget "_:L"))
         (setq p (getpoint "\nSpecify basepoint: "))
       )
       (if (vl-cmdf "_.move" s "" "_non" p "\\")
         (if (equal p (getvar 'lastpoint) 1e-
               (princ "\nUser pressed Enter.")
               (princ "\nUser clicked a point.")
         )
         (princ "\nUser pressed Esc.")
       )
   )
   (princ)
)

Costinbos77 发表于 2022-7-6 07:20:47

谢谢你的回复。
 
不知怎的,有一个AutoCAD变量表示表达式是否已执行?

Costinbos77 发表于 2022-7-6 07:28:30

在这里,我使用了这个决定:
 

(defun c:Test ()
(setq i 1 ) ;_ end of setq
   (while
    (progn
   (setq nms (itoa i)) ;_ end of setq
   (command "text" "m"'(0 0 0) 0.2 0 nms) ;_ end of c
   (setq lo (entget (entlast))) ;_ end of setq
   (princ (strcat "\n   Choose place for TEXT:" nms ";Any = Stop ;< Pick>: ")) ;_ end of p
   (vl-catch-all-apply '(lambda nil (command "_move" (entlast) "" '(0 0 0) pause))) ;_ end of vl
   (if (equal lo (entget (entlast))) nil T) ;_ end of if
    ) ;_ end of prog cond
    (setq i (1+ i)) ;_ end of setq
   ) ;_ end of wh p
   (entdel (entlast))
) ; end


 
试试这个应用程序对于插入迭代文本很有用。

Lee Mac 发表于 2022-7-6 07:31:49

我想我回答了这个问题

danellis 发表于 2022-7-6 07:38:31

 
也许OP无法解析?
 
原理是,该函数不是测试响应mid命令,而是在*开始执行move命令之前*请求点并检查它。
 
dJE

GP_ 发表于 2022-7-6 07:41:21

 
 
如果该函数用于输入迭代文本,为什么不使用lisp n°1?

Costinbos77 发表于 2022-7-6 07:49:46

这就是GP_是一个lisp应用程序1号。我试图得到一些东西,但我不知道如何解决这个问题。非常感谢李的帮助和分享他的经验。

Lee Mac 发表于 2022-7-6 07:50:44

 
我认为问题在于如何在移动命令的“暂停”期间检测用户的响应,而不是事先测试。
 
代码可以很容易地重新构造为使用两点提示,并在调用命令之前测试用户对这两个提示的响应,但是,这将删除Move命令提供的对象预览,此外,OP需要重新创建Move命令提供的替代选项。
 
我随后作出回应的原因是,OP似乎忽略了我的示例中vl cmdf的使用,支持vl catch all apply、匿名lambda函数和命令表达式的不必要组合。
 
 
不客气,科斯廷伯斯。
页: [1] 2
查看完整版本: 决策问题