vlax调用与catc相交
我在分析李的功能。http://www.lee-mac.com/intersectionfunctions.html
;; Intersections-Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - VLA-Objects
;; mod - acextendoption enum of intersectwith method
(defun LM:intersections ( ob1 ob2 mod / lst rtn )
(if (and (vlax-method-applicable-p ob1 'intersectwith)
(vlax-method-applicable-p ob2 'intersectwith)
(setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
)
(repeat (/ (length lst) 3)
(setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
lst (cdddr lst)
)
)
)
(reverse rtn)
)
我注意到,如果坐标较大,该函数将捕捉相邻的段。
示例1:两条多段线相交。
(LM:intersections (vlax-Ename->Vla-Object (car (entsel))) (vlax-Ename->Vla-Object (car (entsel))) acextendnone)
LWPOLYLINE 1: ((-0.112 0.093) (0.296 0.085) (0.717 0.255))
LWPOLYLINE 2: ((-0.043 0.177) (0.08 0.003) (0.234 0.177) (0.323 -0.022) (0.373 0.227))
返回4个正确的点。
((0.0180291 0.090385 0.0) (0.155541 0.0875826 0.0) (0.275268 0.0851427 0.0) (0.34906 0.106104 0.0))
示例2:转换的两条LW多段线的交点。
LWPOLYLINE 1: ((8405375.127 5679451.655) (8405375.535 5679451.647) (8405375.955 5679451.818))
LWPOLYLINE 2: ((8405375.195 5679451.739) (8405375.319 5679451.565) (8405375.473 5679451.739) (8405375.562 5679451.54) (8405375.612 5679451.789))
返回6分。4正确,2不正确。
((8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0))
计算交点时,将对象移动到坐标系起点的唯一解决方案是什么? 不幸的是,这是intersectwith方法的一个已知错误-前面已经讨论过。 有趣的是,但是我无法复制这个bug。。。
我想建议使用像李提供的polyinters这样的函数(不知道他已经写了这样的东西)。
我所知道的intersectwith方法的唯一失败是:
(setq rtn ; in case the object is self intersecting
(cons; but the problem is that this considers LWPOLY's/SPLINE's mid vertices as intersections (i.e. all vertices, except the endpoints)
(vlax-list->3D-point (vlax-invoke o1 'InterSectWith o1 acExtendNone))
rtn
)
); setq rtn
顺便说一句,Lee函数的一种变体,使用vlax curveGetPointAtParam在分段处分割曲线,并对两个曲线对象的每对分段使用inters,可能“完成了这项工作”,尽管这种方法在精度和速度性能上会有所不同。也许这个想法更有效的方法是把它和这个结合起来。
页:
[1]