Remove duplicate x an y coordinates from list

Remove duplicate x an y coordinates from list

avinash00002002
Collaborator Collaborator
815 Views
9 Replies
Message 1 of 10

Remove duplicate x an y coordinates from list

avinash00002002
Collaborator
Collaborator

Hi!

 

I required to remove X and Y coordinate from point list with some conditions.

1. Remove all lesser Y points when remove  X   (Greater y point list shall be there)

2. Remove all greater Y points when remove Y (Lesser X point list shall be there)

eg. ((2330.51 566.281 0.0) (2308.01 588.781 0.0) (2330.51 588.781 0.0) (2308.01 566.281 0.0))

after removing:

((2330.51 588.781 0.0) (2308.01 566.281 0.0))

 

Thanks,

 

Avinash

 

0 Likes
816 Views
9 Replies
Replies (9)
Message 2 of 10

avinash00002002
Collaborator
Collaborator

(defun x_dupl (l) (if l (cons (car l) (x_dupl (vl-remove-if '(lambda (a) (equal (car a) (caar l) 1e-8) ) (cdr l) ) ) ) ) )

0 Likes
Message 3 of 10

dbroad
Mentor
Mentor

The following works to return the lower left and upper right corner of a list of points, always returning 2 points(lower left corner and upper right corner in that order, giving the extents of the points list).  If this doesn't meet your need, describe your problem better and provide more example lists and results.  Keep in mind, there is a difference between a coordinate and a point.  Make that difference clear in your explanations.

 

(defun corners (points)
  (list
    (apply 'mapcar (cons 'min points))
    (apply 'mapcar (cons 'max points))))

 

 

Architect, Registered NC, VA, SC, & GA.
Message 4 of 10

avinash00002002
Collaborator
Collaborator

Hi

 

I am attaching routing for your reference.

 

Thanks

0 Likes
Message 5 of 10

dbroad
Mentor
Mentor

In this case, a picture without words means nearly nothing.  Describe your problem.  Will there always be four points?  Why do you want to keep the coordinates for the upper left and lower right rather than the lower left and upper right?  What does the square polyline and trapezoidal polyline have to do with anything?  All I can tell so far is that your point list is the insertion points of the 4 blocks.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 6 of 10

Kent1Cooper
Consultant
Consultant

@dbroad wrote:

....  Will there always be four points?  ....


... and will they always be arranged in an orthogonal rectangle?  What kind of result would you want if they're something like this?

Kent1Cooper_0-1643291108104.png

or even if they're in a rectangle, but not orthogonally oriented?

Kent1Cooper_0-1643291288848.png

Kent Cooper, AIA
0 Likes
Message 7 of 10

avinash00002002
Collaborator
Collaborator

Hi!

not always four points described by you. I am attaching more plate drawings. 

 

if any holes more than one in line in horizontal line or vertical line only it will take only one hole.

so, while putting dimensions by lisp no dimensions are overlapped. as per attached drawing.

 

Thanks

0 Likes
Message 8 of 10

avinash00002002
Collaborator
Collaborator

You can check all yellow boxed dimensions are overlapped. that I don't want. I have to delete every time.

0 Likes
Message 9 of 10

Kent1Cooper
Consultant
Consultant

@avinash00002002 wrote:

.... I am attaching more plate drawings. .... as per attached drawing.


[Nothing was attached.]

Kent Cooper, AIA
0 Likes
Message 10 of 10

CodeDing
Advisor
Advisor

@dbroad ,

 


 

(defun corners (points)
  (list
    (apply 'mapcar (cons 'min points))
    (apply 'mapcar (cons 'max points))))

 


I just wanted to jump in here and say that this is one of the most simple, elegant, and practical functions I've seen. It still amazes me how every once in a while these come along. Just when you think there couldn't possibly be any more. I enjoy coming across these.

 

Best,

~DD