使用while函数来循环,下面是一个计算交点的autolisp代码:
(defun c:tes ( / &k1 &kw1 &ss1 &ss2 i x)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(if (null vlax-dump-object) (vl-load-com) )
(princ "\n请选择曲线")
(if (setq &kw1 (ssget '((0 . "*LINE,ARC,CIRCLE,ELLIPSE,HELIX"))))
(progn
(setq &ss1 '() i -1.0)
(while (setq &k1 (ssname &kw1 (setq i (1+ i))))
(setq &ss1 (cons &k1 &ss1));提取对象
);while
(while (and (setq &k1 (car &ss1)) (setq &ss1 (cdr &ss1)));计算这条曲线与其他对象的交点
(setq &ss2 (apply 'append (vl-remove-if '(lambda (x) (= x nil))
(mapcar '(lambda (x) (acet-geom-intersectwith &k1 x 0)) &ss1))))
;&ss2是计算得到的交点,没有交点的话是nil
);while;2
)
)
(princ)
)