新人自学写了一个标记两条直线交点的程序,entsel空选就循环继续选直到选中,请大神们帮我看看怎么按空格或回车能退出循环,不按空格或回车就一直循环选下去。附代码
- ;标记两条直线交点
- (defun c:ttt( / e1 e2 ent1 ent2 p11 p12 p21 p22 pt s1 s2 ss)
- (setvar "cmdecho" 0)
- (while T
- (setq e1 (entsel "\n选取第一条线:"))
- (while (= e1 nil)
- (setq e1 (entsel "\n选取第一条线:"))
- )
-
- (setq e2 (entsel "\n选取第二条线:"))
- (while (= e2 nil)
- (setq e2 (entsel "\n选取第二条线:"))
- )
- (if (and e1 e2)
- (progn
- (setq ent1 (entget(car e1)))
- (setq p11 (cdr (assoc 10 ent1)))
- (setq p12 (cdr (assoc 11 ent1)))
- (setq ent2 (entget(car e2)))
- (setq p21 (cdr (assoc 10 ent2)))
- (setq p22 (cdr (assoc 11 ent2)))
- (setq pt (inters p11 p12 p21 p22 nil))
- (if (= pt nil)
- (alert "\n所选的两条线为平行线,重选或退出")
- (progn
- (if (< (distance pt p11) (distance pt p12))
- (command "LINE" pt p11 "")
- (command "LINE" pt p12 "")
- )
- (setq s1 (entlast))
- (if (< (distance pt p21) (distance pt p22))
- (command "LINE" pt p21 "")
- (command "LINE" pt p22 "")
- )
- (setq s2 (entlast))
- (setq ss (ssadd))
- (ssadd s1 ss)
- (ssadd s2 ss)
- (command "_.scale" ss "" pt 0.35)
- )
- )
- )
- )
-
- )
- (princ)
- )
|