Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

vl-remove points

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
dicra
549 Views, 8 Replies

vl-remove points

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?

 

 

 

 

8 REPLIES 8
Message 2 of 9
Kent1Cooper
in reply to: dicra

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.

Kent Cooper, AIA
Message 3 of 9
stevor
in reply to: dicra

You can use the 'Equal, as per Kent, which is useful anyway, or, use the 4 Modes, 0 1 2 3 to find int pts for each case.
S
Message 4 of 9
dicra
in reply to: stevor

stevor,

 

Can You give me a bit more further explanation, about which modes do You mean?

Message 5 of 9
stevor
in reply to: dicra

Modes for 'intersectwith:

 

http://www.lee-mac.com/intersectionfunctions.html

 

are at 'Mode Intersection Behaviour'

and the values are 0 1 2 3.

 

 

S
Message 6 of 9
Lee_Mac
in reply to: dicra

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

Message 7 of 9
stevor
in reply to: dicra

 

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))

 

S
Message 8 of 9
dicra
in reply to: Lee_Mac

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.

Message 9 of 9
Lee_Mac
in reply to: dicra

dicra wrote:

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost