TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: abe123456789 on July 21, 2022, 09:09:38 PM
-
How can I sort a list of points perpendicular to a line going towards the line? I found this code to sort points but does not give me control any help will be appreciated. I attached a drawing to illustrate what I am meaning.
Thank you,
(vl-sort ptlist
'(lambda (x y)
(if (= (car x) (car y))
(< (cadr x) (cadr y))
(< (car x) (car y)))
))
-
Maybe you can sort them by distance from the line.
So something along these lines:
For a lot of points you might want to cache the distances calculated in the list and sort on those so they don't have to be checked all the time.
-
lets say we got a list of points( 7 1 0) (6 1 0) (5 1 0) ( 4 1 0)
and we got a line with the start pt (8 3 0) and the line end pt ( 8 1 0)
How can i sort the list of points going towards the line?
-
lets say we got a list of points( 7 1 0) (6 1 0) (5 1 0) ( 4 1 0)
and we got a line with the start pt (8 3 0) and the line end pt ( 8 1 0)
How can i sort the list of points going towards the line?
How do you want them sorted?
What if there are point on the right of the line? (8 1 0) (9 1 0) (10 1 0) (11 1 0)
What if the line is reversed? from ( 8 1 0) to (8 3 0)
What if the line and the points are completely random?
-
Maybe this?
https://www.cadtutor.net/forum/topic/66657-perpendicular-lines-from-many-points-to-a-polyline/#comment-546306
-
lets say we got a list of points( 7 1 0) (6 1 0) (5 1 0) ( 4 1 0)
and we got a line with the start pt (8 3 0) and the line end pt ( 8 1 0)
How can i sort the list of points going towards the line?
How do you want them sorted?
What if there are point on the right of the line? (8 1 0) (9 1 0) (10 1 0) (11 1 0)
What if the line is reversed? from ( 8 1 0) to (8 3 0)
What if the line and the points are completely random?
I like the vl-sort i posted but i want to add the control where it goes in the direction of the line.
there wouldnt be point to the right of the line
the points wouldnt be random.
-
If its points like in crossing parallel lines then yes dexus is correct use sort on distance but your list would be like ((dist x y)(dist x y) (dist x y) where dist is distance from a pt on line to new points. I use this method often. Maybe also closestpointto where perp is required.
-
... i want to add the control where it goes in the direction of the line.
there wouldnt be point to the right of the line
the points wouldnt be random.
If there are no points on the right, then sorting by X is enough, maybe just changing "<" to ">", you first code should do it.
Sorry, but for me, "control where it goes in the direction of the line" has no meaning.
Better draw some points, draw a line, label the points in the order you want them. Repeat for other situations. Post a screenshot.
-
https://www.cadtutor.net/forum/topic/33845-lisp-multi-level-sorting/?fbclid=IwAR2Dn1YVrDL-AykmSAH_qGszOLZ6he6ZnmtPMMZxy4_5QRyGjF5LETJqS64
-
The other thing to look at "Is it left or right" lee_mac has a routine that checks this so could make dist -ve for left and +ve for right sort should still work.