# Thread: max and min coordinate in polyline

1. ## max and min coordinate in polyline

Registered forum members do not see this ad.

hello everyone, i want an autolisp function to get maximum and minimum coordinate in a polyline, such as below image A is min and B is max Coordinates that i want to get them.

A = (x,y)
B = (x,y)

2. Try this function :

Code:
```(defun get:min (l)
(list	(apply 'min (mapcar 'car l))
)
)```
Example :
Code:
```_\$ (get:min '((1 6)(2 5)(3 4)))
(1 4)```
Use (get:min (list a b)) in your case

3. Code:
```(defun c:plminmax ( / lw pl pmin pmax )
(while
(or
(not (setq lw (car (entsel "\nPick LWPOLYLINE..."))))
(if lw
(/= (cdr (assoc 0 (entget lw))) "LWPOLYLINE")
)
)
(prompt "\nMissed or picked wrong entity type...")
)
(setq pl (mapcar '(lambda ( p ) (trans (list (car p) (cadr p) (cdr (assoc 38 (entget lw)))) lw 0)) (mapcar 'cdr (vl-remove-if  '(lambda ( x ) (/= (car x) 10)) (entget lw)))))
(setq pmin  (car (setq pl (vl-sort pl '(lambda ( a b ) (if (equal (cadr a) (cadr b)  1e-8) (< (car a) (car b)) (< (cadr a) (cadr b))))))))
(setq pmax (last pl))
(prompt "\nA - pmin = ")(princ pmin)
(prompt "\nB - pmax = ")(princ pmax)
(princ)
)```

4. \$0.02 - 'bounding box' should return min max as well

5. thank you all,,, my problem has been resolved by your help.

6. Originally Posted by satishrajdev
Try this function :

Code:
```(defun get:min (l)
(list	(apply 'min (mapcar 'car l))
)
)```
Example :
Code:
```_\$ (get:min '((1 6)(2 5)(3 4)))
(1 4)```
Use (get:min (list a b)) in your case
Originally Posted by hanhphuc
\$0.02 - 'bounding box' should return min max as well
Such solutions will not necessarily yield a point on the polyline.

7. What about the coordinates of:

EDIT: I just realized its too easy for any shape

Lisp Code

8. Originally Posted by Lee Mac
Such solutions will not necessarily yield a point on the polyline.
oops, i misunderstood. In case polyline has bulge, i thought OP looking merely min max like bbox
thanks Lee

9. Originally Posted by hanhphuc
bbox
Oddly enough, that's exactly what i use: [ code removed from link ]

Code:
```(defun c:HiLow (/ obj pts)
(while (setq obj (Car (entsel)))
(progn
(vla-getboundingbox (vlax-ename->vla-object obj) 'll 'ur)
(setq pts	(mapcar	'(lambda (p)
(vlax-curve-getClosestPointToProjection
obj
(vlax-safearray->list p)
'(1.0 0.0 0.0)
)
)
(list ll ur)
)
)
;;	for showing the points		;;
(Foreach p pts
(entmakex (list	(cons 0 "POINT")
(cons 10 p)
)
)
)
)
)
)```

10. Registered forum members do not see this ad.

Originally Posted by pBe
Oddly enough, that's exactly what i use: [ code removed from link ]

Code:
`(defun c:HiLow (/ obj pts) .... )`
BingoBox finally explained doubt thanks

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts