AutoLISP利用repeat循环取得多段线顶点坐标,代码如下。
(defun c:plpoint ()
(setq i 0)
(setq pline (car (entsel)))
(setq ent (entget pline))
(setq pts nil)
(repeat (length ent)
(if (= (car (nth i ent)) 10)
(setq pts (append pts (list (cdr (nth i ent)))))
)
(setq i (1+ i))
)
(print pts)
(princ)
)
代码完。
利用foreach函数取得多段线定点,代码如下。
(defun c:plpoint ()
(setq pline (car (entsel)))
(setq ent (entget pline))
(setq pts nil)
(foreach lst ent
(if (= (car lst) 10)
(setq pts (append pts (list (cdr lst))))
)
)
(print pts)
(princ)
)
代码完。