允许用户选择exa
我需要知道用户选择的线的端点(p1和p2)。我怎么能让他们只选一行?我目前正在使用以下软件:(if (setq ss (ssget'((0 . "LINE"))))
(setq l1ent (entget (ssname ss 0)))
(setq p1 (cdr (assoc 10 l1ent)))
(setq p2 (cdr (assoc 11 l1ent)))
这是可行的,但它仍然允许用户抓取比需要更多的对象。我想我需要使用entsel,但是如果他们选择了不同的对象呢?我需要创建一个while循环来不断提示他们,直到他们选择一行,还是这个功能内置在entsel中? (setq SS (ssget "_+.:E:S" (list (cons 0 "LINE"))))
有关更多信息,请阅读此处。
编辑:您还可以强制选择:
(while (not (setq SS (ssget "_+.:E:S" (list (cons 0 "LINE"))))) SS) 您可以将ENTSEL与以下循环一起使用。我用简单的方式写了它,让你们理解。
(while (not flag)
(setq a (car (entsel "\nSelect Line : ")))
(cond ((null a) (alert "Nothing selected, Please try again."))
((= (cdr (assoc 0 (entget a))) "LINE")
(alert "Selected object is line, Quitting the loop now.")
(setq flag t)
)
(t (alert "Selected object is not line, Please try again."))
)
) 太好了,谢谢satishrajdev!我尝试了Grrr的方法,但如果单击任何非行的内容,代码就会结束,提示仍然显示Select Objects(复数)。
享受干杯
页:
[1]