AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN


Applying Points.

I received this from Roger Farley:

I was browsing your tips and tricks area and thought I would contribute a gem:

These four lines will give you the extreme four values in a points list:
where PointList is a list of 2D or 3D points (like a list of pline vertex points),

(setq X1 (apply 'min (mapcar 'car PointList)))
; The smallest 'X' value
(setq Y1 (apply 'min (mapcar 'cadr PointList)))
; The smallest 'Y' value
(setq X2 (apply 'max (mapcar 'car PointList)))
; The largest 'X' value
(setq Y2 (apply 'max (mapcar 'cadr PointList)))
; The largest 'Y' value

Then assemble like:

(setq LowerLeft (List X1 Y1))
(setq LowerRight (List X2 Y1))
(setq UpperRight (List X2 Y2))
(setq UpperLeft (List X1 Y2))

or

(setq CPWin (list (List X1 Y1) (list X2 Y1)
	    (list X2 Y2) (list X1 Y2)))
;A list of 4 points, can be passed to a 'ssget' function

I use the trick in finding an extents boundary around the objects
I am working with, or performing a zoom window around the work area.

Roger Farley

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright © 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website