RepCad Posted July 11, 2018 Posted July 11, 2018 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) thanks in advanced. Quote
satishrajdev Posted July 11, 2018 Posted July 11, 2018 Try this function : (defun get:min (l) (list (apply 'min (mapcar 'car l)) (apply 'min (mapcar 'cadr l)) ) ) Example : _$ (get:min '((1 6)(2 5)(3 4))) (1 4) Use (get:min (list a b)) in your case Quote
marko_ribar Posted July 11, 2018 Posted July 11, 2018 (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- (< (car a) (car b)) (< (cadr a) (cadr b)))))))) (setq pmax (last pl)) (prompt "\nA - pmin = ")(princ pmin) (prompt "\nB - pmax = ")(princ pmax) (princ) ) Quote
hanhphuc Posted July 11, 2018 Posted July 11, 2018 $0.02 - 'bounding box' should return min max as well Quote
RepCad Posted July 11, 2018 Author Posted July 11, 2018 thank you all,,, my problem has been resolved by your help. Quote
Lee Mac Posted July 11, 2018 Posted July 11, 2018 Try this function : (defun get:min (l) (list (apply 'min (mapcar 'car l)) (apply 'min (mapcar 'cadr l)) ) ) Example : _$ (get:min '((1 6)(2 5)(3 4))) (1 4) Use (get:min (list a b)) in your case $0.02 - 'bounding box' should return min max as well Such solutions will not necessarily yield a point on the polyline. 1 Quote
pBe Posted July 11, 2018 Posted July 11, 2018 (edited) What about the coordinates of: EDIT: I just realized its too easy for any shape pseudo code --> enclosure+crate+adjacent+extension+horizontal Lisp Code Edited July 11, 2018 by pBe 1 Quote
hanhphuc Posted July 12, 2018 Posted July 12, 2018 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 Quote
pBe Posted July 12, 2018 Posted July 12, 2018 bbox Oddly enough, that's exactly what i use: [ code removed from link ] (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) ) ) ) ) ) ) 1 Quote
hanhphuc Posted July 12, 2018 Posted July 12, 2018 Oddly enough, that's exactly what i use: [ code removed from link ] (defun c:HiLow (/ obj pts) .... ) BingoBox finally explained doubt thanks 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.