本帖最后由 作者 于 2007-12-2 9:41:51 编辑
;;;----通用函数----- ;;选择集->图元名表 (defun ss->elst (ss / elst) (setq i 0) (repeat (sslength ss) (setq elst (cons (ssname ss i) elst) i (1+ i) ) ) (reverse elst) ) ;;;删除列表中的相同元素(保留一个)并返回新表 (defun LstDelSame (lst / x nl) (foreach x lst (if (not (member x nl)) (setq nl (cons x nl)) ) ) (setq nl (reverse nl)) nl ) (defun c:tt (/ ELST O1 O2 P PLST PLST0 SS) (princ "\n选择所有的交线.") (setq ss (ssget (list (cons 0 "*POLYLINE,LINE")))) (setq elst (ss->elst ss)) (foreach e elst (setq o1 (vlax-ename->vla-object e)) (foreach e elst (setq o2 (vlax-ename->vla-object e)) (setq p (vlax-invoke o1 'intersectwith o2 acextendnone)) (setq plst0 (cons p plst0)) ) ) (setq plst2 (vl-remove nil (LstDelSame plst0))) ) 得到((29.0888 21.4991 0.0) (33.789 15.9458 0.0) (29.0888 21.4991 0.0) (33.789 15.9458 0.0)) 得到的任意线的交点表,是有重复的点. LstDelSame 没作用... ---------------------------------------------------------------------------------------------------------- 可是: (LstDelSame '((29.0888 21.4991 0.0) (33.789 15.9458 0.0) (29.0888 21.4991 0.0) (33.789 15.9458 0.0))) 得到((29.0888 21.4991 0.0) (33.789 15.9458 0.0)) 又是对的.... (setq aaa '((29.0888 21.4991 0.0) (33.789 15.9458 0.0) (29.0888 21.4991 0.0) (33.789 15.9458 0.0))) (LstDelSame aaa) 得到((29.0888 21.4991 0.0) (33.789 15.9458 0.0)) 也是对的....
|