(setq PtA (vlax-safearray->list (vlax-variant-value retCoordA))
PtB (vlax-safearray->list (vlax-variant-value retCoordB))
)
(if (vl-every '(lambda (q p) (equal q p 1e-8)) PtA PtB)
(alert "Objects are the same")
(alert "Objects are different")
)
Even when the objects are the same, it returns that they are different.
Command: (setq lst-1 '(9.34785 4.79562 9.34785 5.55109 10.2356 5.55109 10.2356
4.79562))
(9.34785 4.79562 9.34785 5.55109 10.2356 5.55109 10.2356 4.79562)
Command: (setq lst-2 '(9.34785 5.55109 9.34785 4.79562 10.2356 5.55109 10.2356
4.79562))
(9.34785 5.55109 9.34785 4.79562 10.2356 5.55109 10.2356 4.79562)
Command: (vl-every '(lambda ( x ) (eq x T)) (mapcar '(lambda ( x ) (vl-some
'(lambda ( y ) (equal x y 1e-5)) lst-1)) lst-2))
T
Command: (vl-every '(lambda (q p) (equal q p 1e-8)) lst-1 lst-2)
nil
Code - Auto/Visual Lisp: [Select]The same as Tharwat explained lst-1 and lst-2 are point lists...
... to see if the list points are identical...Do you want to check if the polylines overlap? If so, the order of the points is still important. Also the OCS and the elevation should be taken into account.
(setq lst-1 '(9.34785 4.79562 9.34785 5.55109 10.2356 5.55109 10.2356 4.79562))
(setq lst-2 '(9.34786 4.79563 9.34786 5.55110 10.2357 5.55110 10.2357 4.79563))
Hi
To compare two list without vl-every
< ... >
(equal lst-1 lst-2 1e-4) --> T
(equal lst-1 lst-2 1e-5) --> nil
This only seems to work if the order is identical.Hi
To compare two list without vl-every
< ... >
(equal lst-1 lst-2 1e-4) --> T
(equal lst-1 lst-2 1e-5) --> nil
:-)
< .. >
This only seems to work if the order is identical.
... to see if the list points are identical...Do you want to check if the polylines overlap? If so, the order of the points is still important. Also the OCS and the elevation should be taken into account.
Yes, the goal is to see if the two lists are identicalThis only seems to work if the order is identical.Hi
To compare two list without vl-every
< ... >
(equal lst-1 lst-2 1e-4) --> T
(equal lst-1 lst-2 1e-5) --> nil
:-)
(equal (vl-sort lst-1 '<) (vl-sort lst-2 '<) 1e-4)
Now, if the order does not matter, we can doCode: [Select](equal (vl-sort lst-1 '<) (vl-sort lst-2 '<) 1e-4)
@+
_$ (setq lst-1 '(1 2 3 4 4 5) lst-2 '(1 2 2 3 4 5))
(1 2 2 3 4 5)
_$ (equal (vl-sort lst-1 '<) (vl-sort lst-2 '<) 1e-4)
T
Now, if the order does not matter, we can doCode: [Select](equal (vl-sort lst-1 '<) (vl-sort lst-2 '<) 1e-4)
@+
Be careful with vl-sort:Code: [Select]_$ (setq lst-1 '(1 2 3 4 4 5) lst-2 '(1 2 2 3 4 5))
(1 2 2 3 4 5)
_$ (equal (vl-sort lst-1 '<) (vl-sort lst-2 '<) 1e-4)
T
(defun f ( lst-1 lst-2 )
(if (and (listp (car lst-1)) (listp (car lst-2)))
(equal
(mapcar 'nth
(vl-sort-i lst-1 '(lambda ( a b ) (< (distance '(0.0 0.0 0.0) a) (distance '(0.0 0.0 0.0) b))))
(mapcar '(lambda ( x ) lst-1) lst-1)
)
(mapcar 'nth
(vl-sort-i lst-2 '(lambda ( a b ) (< (distance '(0.0 0.0 0.0) a) (distance '(0.0 0.0 0.0) b))))
(mapcar '(lambda ( x ) lst-2) lst-2)
)
1e-4
)
(equal
(mapcar 'nth
(vl-sort-i lst-1 '<)
(mapcar '(lambda ( x ) lst-1) lst-1)
)
(mapcar 'nth
(vl-sort-i lst-2 '<)
(mapcar '(lambda ( x ) lst-2) lst-2)
)
1e-4
)
)
)
I am stating the obvious here: Sorting a flat list of reals representing alternating X and Y coordinates of 2D points makes little sense.
Oh yes, you are right, I had not seen that vl-sort truncates the result with integerNow, if the order does not matter, we can doCode: [Select](equal (vl-sort lst-1 '<) (vl-sort lst-2 '<) 1e-4)
@+
Be careful with vl-sort:Code: [Select]_$ (setq lst-1 '(1 2 3 4 4 5) lst-2 '(1 2 2 3 4 5))
(1 2 2 3 4 5)
_$ (equal (vl-sort lst-1 '<) (vl-sort lst-2 '<) 1e-4)
T
Oh yes, you are right, I had not seen that vl-sort truncates the result with integerOnly with integers:
(vl-sort '(3 2 1 3 1 2 2 2 1.0 1.0 1.0 1.0) '<)
(1 1.0 1.0 1.0 1.0 2 3)
(vl-sort '("a" "A" "a") '<)
("A" "a" "a")
(vl-sort '("a" "A" "a" "A") '<)
("A" "A" "a" "a")
Yes, I am using the boundary command to generate plines and as a result there are some instances where a duplicate polyline gets created but with a different order for the points. This causes the overkill command to fail to identify that they are identical and delete the duplicate. Basically, the polylines need to be identical, but the order that the points were drawn in do not need to be identical.< .. >
This only seems to work if the order is identical.
Yes,
I tried to visualise the use for comparing point lists where the point order does not matter.
.... wasn't successful.
Care to share the purpose of the test ?