;; Collinear-p - Lee Mac
;; Returns T if p1,p2,p3 are collinear
(defun LM:Collinear-p ( p1 p2 p3 )
(
(lambda ( a b c )
(or
(equal (+ a b) c 1e-4)
(equal (+ b c) a 1e-4)
(equal (+ c a) b 1e-4)
)
)
(distance p1 p2) (distance p2 p3) (distance p1 p3)
)
)
(defun Ale_Pline_LwVertices (EntObj / VrtIdx VrtInf OutLst) ; EntObj = VLA-OBJECT or ENAME
(setq VrtIdx (1+ (vlax-curve-getEndParam EntObj)))
(while (> VrtIdx 0)
(setq
VrtInf (vlax-curve-getPointAtParam EntObj (setq VrtIdx (1- VrtIdx)))
OutLst (cons VrtInf OutLst)
)
)
)
(defun C:test ( / VtxLst VtxLs1 VtxLs2 OutLen)
(setq
VtxLs1 (Ale_Pline_LwVertices (car (entsel "Poly perimeter: ")))
VtxLs2 (Ale_Pline_LwVertices (car (entsel "Poly rectangle: ")))
VtxLst VtxLs1
)
(while (cdr VtxLs2)
(while (cdr VtxLs1)
(if
(and
(LM:Collinear-p (car VtxLs1) (cadr VtxLs1) (car VtxLs2))
(LM:Collinear-p (car VtxLs1) (cadr VtxLs1) (cadr VtxLs2))
)
(setq OutLen (distance (car VtxLs2) (cadr VtxLs2)) VtxLs1 nil VtxLs2 nil)
(setq VtxLs1 (cdr VtxLs1))
)
)
(setq VtxLs2 (cdr VtxLs2) VtxLs1 VtxLst)
)
OutLen
)
With the "test" function I can calculate the length of the gray segments, how can I calculate the length of the green segments?