Points from a list

Points from a list

carlos_m_gil_p
Advocate Advocate
894 Views
3 Replies
Message 1 of 4

Points from a list

carlos_m_gil_p
Advocate
Advocate

Hello boys how are you.
They could help me with a list of points.
I have a list of points extracted from drawn rectangles.
From that list of points, I need to extract the lower left point and the upper right point.

 

Example one:

Original list ((1.0 1.0) (5.5 1.0) (5.5 4.0) (1.0 4.0))
Result ((1.0 1.0) (5.5 4.0))

 

Example two:

Original list ((15.5 9.0) (11.0 9.0) (11.0 6.0) (15.5 6.0))
Result ((15.5 9.0) (11.0 6.0))

 

Thank you.

Excuse my English, I only speak Spanish.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Accepted solutions (1)
895 Views
3 Replies
Replies (3)
Message 2 of 4

ronjonp
Mentor
Mentor
Accepted solution

Are your rectangles all orthogonal ? If so use the boundingbox method:

(if (setq e (car (entsel)))
  (progn (vla-getboundingbox (vlax-ename->vla-object e) 'll 'ur)
	 (mapcar 'vlax-safearray->list (list ll ur))
  )
)

Or use this for your point list ... although it's still the bounding box. 

(setq l '((1.0 1.0) (5.5 1.0) (5.5 4.0) (1.0 4.0)))
(list (apply 'mapcar (cons 'min l)) (apply 'mapcar (cons 'max l)))
Message 3 of 4

Sea-Haven
Mentor
Mentor

Using sort x y

(setq lst (list (list 15.5 9.0) (list 11.0 9.0) (list 11.0 6.0) (list 15.5 6.0)))
(setq lst (vl-sort lst '(lambda (x y)
(cond
((= (cadr x)(cadr y))
(< (car x)(car y)))
((< (cadr x)(cadr y)))
))))
Message 4 of 4

carlos_m_gil_p
Advocate
Advocate

Hi guys, thanks for the help.

Greetings.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes