明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1555|回复: 5

[已解答] 请问一下这个循环怎么用右键退出

[复制链接]
发表于 2014-7-8 15:07:04 | 显示全部楼层 |阅读模式
(defun C:t00 ()
(while t
  (command "dimdiameter")
  (while (/= (getvar "CMDACTIVE") 0) (command PAUSE))
)
(princ)
)
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2014-7-8 15:11:44 | 显示全部楼层
当while后面为nil时就退出了,你写成T当然不退出了
 楼主| 发表于 2014-7-8 15:38:43 | 显示全部楼层
本帖最后由 zkq1212 于 2014-7-8 15:44 编辑
自贡黄明儒 发表于 2014-7-8 15:11
当while后面为nil时就退出了,你写成T当然不退出了

当while后面为nil时就直接退出了,一次都不执行了。我想可以重复标注圆,也就是下面程序的效果
(defun c:33 ()
(setq clay (getvar "clayer"))
(command "Layer" "s" "03-标注层" "")
(while (setq p(entsel "\n指定新的标注:"))
(command"dimdiameter")(getvar"cmdactive")(command p)
    (while(/=(getvar"cmdactive")0)(command pause))
)
(command "Layer" "s" clay "")
(princ)
)

点评

所以,while后跟变量  发表于 2014-7-8 15:44
 楼主| 发表于 2014-7-8 15:52:47 | 显示全部楼层
(defun C:t00 ()
(setq        ent (entlast)
        key t
  )

(while key
  (command "dimdiameter")

  ;(while (/= (getvar "CMDACTIVE") 0) (command PAUSE))
)
(princ)
)
那么变量如何判断鼠标右键?
发表于 2014-7-8 22:10:32 | 显示全部楼层
为什么要用entlast?
如果使用
(while (setq ent(entsel))
(commmand……
)怎样?
发表于 2014-7-9 08:18:33 | 显示全部楼层
  1. (defun c:tt ()
  2. (setvar "CMDECHO" 0)
  3. (while (and (setq s1 (entsel "\n选择圆: "))
  4.                     (wcmatch (cdr(assoc 0 (entget(car s1)))) "ARC,CIRCLE"))
  5.   (command "_.DIMDIAMETER" s1)
  6.   (while (> (getvar "CMDACTIVE") 0) (command PAUSE))
  7. )
  8. (princ)
  9. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-24 07:22 , Processed in 0.185047 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表