Hi, everybody!
I'm having a little problem with using vl-remove on list with points.
I'm trying to compare two lists, one is list of points of intersection whit circle and another object, and second is the same but whit acextendthisentity.
I was using lee-mac function to sort points in lists of points (not list of numbers)
(defun LM:Intersections ( obj1 obj2 mode / l r ) (setq l (vlax-invoke obj1 'intersectwith obj2 mode)) (repeat (/ (length l) 3) (setq r (cons (list (car l) (cadr l) (caddr l)) r) l (cdddr l) ) ) (reverse r) )
So, I would get two lists:
_$ (setq l1 (LM:Intersections a c acextendthisentity))
((2180.22 862.439 0.0) (2694.54 1168.61 0.0))
_$ (setq l2 (LM:Intersections a c acextendnone))
((2694.54 1168.61 0.0))
Later I would use something like this to get point, which is not on the first object (I need extended intersection):
_$ (foreach n l2 (setq l1 (vl-remove n l1)))
And result should be:
((2180.22 862.439 0.0))
But something it just doesn't work. I can't figure out what is the problem, is it precision or something else?
Any other experience whit same problem?
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
My guess is that it is a matter of precision, as you suggest -- because of way-down-a-lot-of-decimal-places-deep tiny differences, which often occur with values resulting from calculations and/or from different originating functions. I wouldn't have expected that with the two functions you list, but there may be something just that tiny bit different in the results they return. Try the (equal) function with a small fuzz factor. It will be more cumbersome, requiring comparison of each point list in one list with each point list in the other list.
Modes for 'intersectwith:
http://www.lee-mac.com/intersectionfunctions.html
are at 'Mode Intersection Behaviour'
and the values are 0 1 2 3.
Hi dicra,
I would suggest something along the following lines:
_$ (setq l1 (LM:Intersections a c acextendthisentity)) ((2180.22 862.439 0.0) (2694.54 1168.61 0.0)) _$ (setq l2 (LM:Intersections a c acextendnone)) ((2694.54 1168.61 0.0)) (setq l1 (vl-remove-if '(lambda ( x ) (vl-some '(lambda ( y ) (equal x y 1e-8)) l2)) l1))
I hope this helps,
Lee
The next question,
for qualifying the points of a list, one way:
(PRINC" PL_EquL ")
; point proof quaLify List 2D,3D Pts, ret 3D of reals
(defunPnt_3D (p / rp e l pf ) (setq pf t)
(cond ((not (and p (Listp p))) nil )
( (= (Length p) 2)
(foreach e p (if (not (and e (numberp e))) (setq pf nil)))
(if pf (list (float (car p)) (float (cadr p)) 0.0 )) )
( (= (Length p) 3)
(foreach e p (if (not (and e (numberp e))) (setq pf nil)))
(if pf (list (float (car p)) (float (cadr p))
(float (caddr p)) )) )) ) ;
; ~= members of Pts List, ams 12DEC98+
(defun PL_EquL (rp pL DD / p rL) ; in,ret 2D or 3D
(foreach p (if (setq rp (Pnt_3D rp)) (reverse pl ))
(if (and (Pnt_3D cp) (equaL rp (Pnt_3D p) DD))
(setq rL (cons p rL) )) ) rL ) ;
Use:
(setq OKPointList ( PL_EqL RefPt PointsList DifferenceDist))
Lee,
Thank You for help.
It was exactly what I was looking for, wanted to do by my self something similar, but you were quicker.
Thanks again.
Lee,
Thank You for help.
It was exactly what I was looking for, wanted to do by my self something similar, but you were quicker.
Thanks again.
You're most welcome dicra - happy to help.
Lee