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)
)
代码完。