AutoLISP查询直线的相关属性
2011-04-11 17:16 精诚所至 金石为开 阅读(653) 评论(0) 编辑 收藏 举报AutoLISP查询直线的相关属性,得到直线的起点、终点、长度和角度,代码如下。
(defun c:lppt ()
(setq ss (car (entsel "\n请选择所要查询的直线:")))
(setq ssob (vlax-ename->vla-object ss))
(Setq len (Vlax-Get ssob 'Length))
(Setq ang (Vlax-Get ssob 'Angle))
(Setq strpt (Vlax-Get ssob 'StartPoint))
(Setq endpt (Vlax-Get ssob 'EndPoint))
(print (strcat "起点:" (rtos (car strpt)) "," (rtos (cadr strpt))))
(print (strcat "终点:" (rtos (car endpt)) "," (rtos (cadr endpt))))
;;; (print (cons (car strpt) (cadr strpt)))
;;; (print (cons (car endpt) (cadr endpt)))
(print (strcat "长度:" (rtos len)))
(print (strcat "角度:" (rtos ang)))
(princ)
)
代码完。
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)