明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1855|回复: 12

请教关于 grread 的问题

[复制链接]
发表于 2020-8-15 11:21:12 | 显示全部楼层 |阅读模式
2明经币
下面程序,为什么第一次运行的时候,会自动默认为  移动鼠标   ?而第一次运行之后的就正常了,望大师们帮修正一下,谢谢了


(defun c:13(/ loop gr sb jp)
(setq loop t)
(grread 1)
(while loop
(setq gr (grread 1) sb (car gr) jp (cadr gr))
(cond

;鼠标左键
((= sb 3)
(setq loop nil)
(princ"\n 左键")
)

;鼠标右键
((= sb 25)
(setq loop nil)
(princ"\n 右键")
)

;鼠标移动
((= sb 5)
(setq loop nil)
(princ"\n 鼠标移动")
)

;键盘
((= sb 2)
(cond
(jp ;(= jp 32) ;空格
(setq loop nil)
(princ"\n 键盘")
)
)
)

)
)
(princ))

最佳答案

查看完整内容

(defun c:tta (/ loop gr sb jp pt) (setq loop t pt (cadr (grread *))) (while loop (setq gr (grread t 8) sb (car gr) jp (cadr gr) ) (cond ((= sb 3)(setq loop nil) (princ "\n 左键") ) ((= sb 25)(setq loop nil) (princ "\n 右键") ) ((and(= sb 5) (> (distance pt jp) (/(getvar'viewsize) 90))) (setq loop ...
发表于 2020-8-15 11:21:13 | 显示全部楼层
(defun c:tta (/ loop gr sb jp pt)
  (setq loop t pt (cadr (grread *)))
  (while loop
    (setq gr (grread t 8)
          sb (car gr)
          jp (cadr gr)
    )
    (cond
      ((= sb 3)(setq loop nil)
       (princ "\n 左键")
      )
      ((= sb 25)(setq loop nil)
       (princ "\n 右键")
      )
      ((and(= sb 5) (> (distance pt jp) (/(getvar'viewsize) 90)))
       (setq loop nil)(princ "\n 鼠标移动")
      )
      ((= sb 2)(setq loop nil)
       (princ "\n 键盘")
      )
    )
  )
  (princ)
)

点评

完美!非常感谢xvjiex大师  发表于 2020-8-17 21:17
回复

使用道具 举报

发表于 2020-8-15 18:22:43 来自手机 | 显示全部楼层
鼠标移动时loop设为T
回复

使用道具 举报

 楼主| 发表于 2020-8-16 20:27:20 | 显示全部楼层
(defun c:13(/ j)
(setq j (sb-jp))
(cond
((= j 5)
(princ"\n 鼠标移动")
)
((= j 3)
(princ"\n 按左键")
)
((= j 25)
(princ"\n 按右键")
)
((= j 2)
(princ"\n 按键盘")
)
)
(princ))

(defun sb-jp(/ sb loop)
(setq loop (cadr (grread *)) sb (car (grread *)))
(grread *)
(while loop

(setq sb (car (grread *)))
(cond
((= sb 3)(setq loop nil)) ;鼠标左键
((= sb 25)(setq loop nil)) ;鼠标右键
((and (= sb 5) (> (distance loop (cadr (grread *))) (/(getvar'viewsize) 90) ) ) (setq loop nil)) ;鼠标移动
((= sb 2)(setq loop nil)) ;按键盘
)
)
sb
)

评分

参与人数 1明经币 +1 收起 理由
xvjiex + 1 已经帮你改好了

查看全部评分

回复

使用道具 举报

发表于 2020-8-17 16:06:58 | 显示全部楼层
已经帮你改好了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
回复

使用道具 举报

 楼主| 发表于 2020-8-17 19:45:21 | 显示全部楼层
xvjiex 发表于 2020-8-17 16:06
已经帮你改好了

谢谢大师热情帮助
回复

使用道具 举报

 楼主| 发表于 2020-8-17 19:57:17 | 显示全部楼层
xvjiex 发表于 2020-8-17 16:06
已经帮你改好了

试过了,鼠标移动时没有提示 (princ"\n 鼠标移动") 只能按 esc 退出循环
我要求的是,移动鼠标,既可以提示 (princ"\n 鼠标移动") 并退出循环
回复

使用道具 举报

发表于 2020-8-17 20:06:09 | 显示全部楼层
本帖最后由 xvjiex 于 2020-8-17 20:10 编辑

你再多试试,移动鼠标肯定有提示 (princ"\n 鼠标移动"),只是行数刷新太快。不退出是我特意设置的,让你理解其功能。你先别着急按esc,点点左键,右键,键盘abc。多试试就理解其含义了。等你理解了,就知道2楼说的很有道理了。
回复

使用道具 举报

 楼主| 发表于 2020-8-17 20:11:44 | 显示全部楼层
xvjiex 发表于 2020-8-17 20:06
你再多试试,移动鼠标肯定有提示 (princ"\n 鼠标移动"),只是行数刷新太快。不退出是我特意设置的,让你理 ...

你在每一项都加 (setq loop nil) 试试,程序一启动,就直接退出了
回复

使用道具 举报

 楼主| 发表于 2020-8-17 20:16:51 | 显示全部楼层
这是我最后修改的,还是存在一个问题,就是右键重复上一次命令的时候,就必须先稍微移动一点点鼠标或按两次相同的按键右或者要先按一次右键再按其它键才能退出
(defun c:13(/ c_c j)
(defun c_c()(princ"\n 999")) ;出错处理
(setq j (sb-jp c_c 50))
(cond
((= j 5)
(princ"\n 鼠标移动")
)
((= j 3)
(princ"\n 按左键")
)
((= j 25)
(princ"\n 按右键")
)
((= j 2)
(princ"\n 按键盘")
)
)
(princ))

(defun sb-jp(error jl / sb loop *error*)
(if (not error) (setq error nil) )
(if (not jl) (setq jl 90) )
(defun *error*(msg)(error)) ;出错处理
(setq loop (cadr (grread *)) sb (car (grread *)))
(grread *)
(while loop
(setq sb (car (grread *)))
(cond
((= sb 3)(setq loop nil)) ;鼠标左键
((= sb 25)(setq loop nil)) ;鼠标右键
((and (= sb 5) (> (distance loop (cadr (grread *))) (/(getvar'viewsize) jl) ) ) (setq loop nil)) ;鼠标移动
((= sb 2)(setq loop nil)) ;按键盘
)
)
sb
)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-21 03:09 , Processed in 1.404506 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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