明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 292|回复: 3

[提问] 求助大神,亮显后按esc中断程序,取消亮显问题

[复制链接]
发表于 2024-7-16 14:32:54 | 显示全部楼层 |阅读模式
本帖最后由 xk2005 于 2024-7-16 14:34 编辑

  下面是我的代码。选择直线后,使用redraw来亮显。如果执行过程中,按下ESC键中断程序,亮显并不能取消。能用怎样的方法在中断后取消亮显呢?



  ;; 检查是否已有预先选择的对象
  (setq sset (ssget "I"))
  (if (and sset (= (sslength sset) 2))
    (progn
      (setq line1 (ssname sset 0))
      (setq line2 (ssname sset 1))
      (print "使用预先选择的线")
    )
    (progn
      ;; 提示用户选择两条线
      (setq line1 (car (entsel "\n请选择第一条线: ")))
      (redraw line1 3)
      (setq line2 (car (entsel "\n请选择第二条线: ")))
      (redraw line2 3)
    )
  )

发表于 2024-7-16 14:45:08 | 显示全部楼层
用*error*处理
发表于 2024-7-16 15:01:12 | 显示全部楼层
发表于 2024-7-16 15:02:08 | 显示全部楼层
  1. (defun c:11 (/ *error* sset line1 line2)
  2. (defun *error*(msg)
  3. (if line1 (redraw line1 4)) ;取消亮显
  4. (if line2 (redraw line2 4)) ;取消亮显
  5. )
  6. (setq sset (ssget "I"))
  7.   (if (and sset (= (sslength sset) 2))
  8.     (progn
  9.       (setq line1 (ssname sset 0))
  10.       (setq line2 (ssname sset 1))
  11.       (print "使用预先选择的线")
  12.     )
  13.     (progn
  14.       ;; 提示用户选择两条线
  15.       (setq line1 (car (entsel "\n请选择第一条线: ")))
  16.       (redraw line1 3)
  17.       (setq line2 (car (entsel "\n请选择第二条线: ")))
  18.       (redraw line2 3)
  19.     )
  20.   )
  21. (princ))


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

本版积分规则

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

GMT+8, 2024-9-24 11:28 , Processed in 0.175536 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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