检查实体类型
大家好,我只是在学习AutoLisp。所以我知道一点。
我想写一个程序,从两条线的交点(如果没有相交,当它们被扩展时)画一条线。
考虑使用Inters函数,效果很好。但现在我想检查所选实体是否为直线。
怎么做?
我写了这样的东西,但它失败了;
(defun c:Intr()
(Setq Line1 (car (entsel "\nSelect First Line:")))
(CheckObject Line1)
BLAH BLAH BLAH.....
)
(defun CheckObject(Enty)
(Setq ObjType(assoc 0 (entget (Enty))))
(if
(/= ObjType "LINE")
(
(alert "No Lines Selected... Ending")
(exit)
)
)
)
请帮忙。。。 您还需要检查它是否是一条多段线,并可能将其分解,以便仍然可以对其进行插入。
明天将在工作中发布此代码。 看看这个。。。。。。
(Setq Line1 (car (entsel "\nSelect First Line:")))
(if (eq (cdr(assoc 0 (entget Line1)))"LINE")
(alert "That's Right")
(alert "I am sorry, That's wrong")
)
塔瓦特 哇!成功了。。。这就是我想要的。
你能告诉我上面的代码哪里出错了吗?
此外,如果用户没有选择一条线,我如何重复该步骤,直到他选择一条线? ENTGET将返回一个点对列表;要获得实体的类型,只需使用第二项——在摘录代码中,您试图将列表(虚线对)与字符串进行比较;此外,实体名称不应括在括号中。请在下面找到您更正的代码:
(defun CheckObject(Enty)
(Setq ObjType (cdr (assoc 0 (entget Enty)))) ;(Enty)))))
(if
(/= ObjType "LINE")
(
(alert "No Lines Selected... Ending")
(exit)
)
)
)
当做
米尔恰 哦我得到了它。。谢谢。。。!!! 这将强制用户只选择一行。。。。
(while
(not
(and (Setq Line1 (car (entsel "\nSelect First Line:")))
(eq (cdr (assoc 0 (entget Line1)))"LINE")
))
(prompt "\n Please select Line onle !!!")
)
谢谢tharwat313。。。。
隐马尔可夫模型。。。这就是为什么我最喜欢这个论坛。。。总是有人在短时间内帮助我。
随时欢迎你。
当做
塔瓦特
页:
[1]