代码改变世界

AutoLISP查询直线的相关属性

2011-04-11 17:16  精诚所至 金石为开  阅读(671)  评论(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)
)

代码完。