Lee Macs intersects lisp

Lee Macs intersects lisp

etilley327KA
Advocate Advocate
643 Views
5 Replies
Message 1 of 6

Lee Macs intersects lisp

etilley327KA
Advocate
Advocate

Im using Lee Macs intersection functions (between sets) to detect when two lines intersect (acextendnone), but it shows intersections at lines that are within a few hundredths but not intersecting. Any idea what could be causing this? Here is the lisp im using to call LM's functions

(defun c:WER ( / ss1 ss2 )
(if (and (setq ss1 (ssget "_X" '((8 . "AP-BUILDING LINE,AP-EASEMENT"))))
(setq ss2 (ssget "_X" '((8 . "00FORMLINE"))))
)
(foreach pnt (LM:intersectionsbetweensets ss1 ss2)
(entmake (list (cons 0 "circle") (cons 10 pnt) (cons 40 1) (cons 39 10) (cons 62 30) (cons 8 "FRMCHK")))
)
)
(if(ssget "_X" (list(cons 8 "FRMCHK")))
(alert "Possible Encroachment")
)
(princ)
)
(vl-load-com) (princ)

0 Likes
Accepted solutions (1)
644 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant

Well, you're too far from 0,0. You gotta move the geometry closer to zero.

 

If you're interested, search about the double floating precision issue.

0 Likes
Message 3 of 6

etilley327KA
Advocate
Advocate

Is there a simple way to account for the linework being so far from 0,0?

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

This could help.

 

(defun :intersections+ ( ob1 ob2 mod / lst rtn pnt p1 p2)
  (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 pnt (list (car lst) (cadr lst) (caddr lst))
	    lst (cdddr lst))
      (if (not (and (not (vl-catch-all-error-p (setq p1 (vl-catch-all-apply 'vlax-curve-getclosestpointto (list ob1 pnt)))))
		    (not (vl-catch-all-error-p (setq p2 (vl-catch-all-apply 'vlax-curve-getclosestpointto (list ob2 pnt)))))
		    (not (equal p1 p2 1e-4))))
	(setq rtn (cons pnt rtn)))))
  (reverse rtn)
  )

 

Message 5 of 6

etilley327KA
Advocate
Advocate

etilley327KA_0-1667834688466.gif

Thank you

 

0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

Well, you're too far from 0,0. You gotta move the geometry closer to zero. ....


[At least it's only in the range of 2,000 miles from the origin.  That's better than some other examples we've seen, with distances such as several times the distance to the moon, or in one case I recall, greater than the diameter of Earth's orbit around the sun.]

Kent Cooper, AIA