+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Feb 2016
    Location
    Australia
    Posts
    30

    Default 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)


    thanks in advanced.
    Attached Images

  2. #2
    Senior Member satishrajdev's Avatar
    Computer Details
    satishrajdev's Computer Details
    Operating System:
    Windows 7 - 64bit
    Computer:
    DELL
    RAM:
    8 GB
    Primary Storage:
    500 GB
    Monitor:
    DELL
    Discipline
    Surveying
    satishrajdev's Discipline Details
    Occupation
    CAD Engineer
    Discipline
    Surveying
    Details
    Design Survey Utilities (i.e. Bathymetry & Geophysical Survey) Design of Survey Planning. Preparation of Alignment Sheets. Programming in AutoCAD.
    Using
    AutoCAD 2014
    Join Date
    Apr 2012
    Location
    Aamchi Mumbai, India
    Posts
    451

    Default

    Try this function :

    Code:
    (defun get:min (l)
      (list	(apply 'min (mapcar 'car l))
    	(apply 'min (mapcar 'cadr l))
      )
    )
    Example :
    Code:
    _$ (get:min '((1 6)(2 5)(3 4)))
    (1 4)
    Use (get:min (list a b)) in your case
    Best Regards,
    Satish Rajdev

    If you ride like there is no tomorrow... Don't worry, there won't be !!!!
    www.facebook.com/satish.rajdev

  3. #3
    Super Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2014
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    1,297

    Default

    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)
    )

    Marko Ribar, d.i.a. (graduated engineer of architecture)
    M.R. on YouTube

  4. #4
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    749

    Default

    $0.02 - 'bounding box' should return min max as well
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  5. #5
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Feb 2016
    Location
    Australia
    Posts
    30

    Default

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

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,600

    Default

    Quote Originally Posted by satishrajdev View Post
    Try this function :

    Code:
    (defun get:min (l)
      (list	(apply 'min (mapcar 'car l))
    	(apply 'min (mapcar 'cadr l))
      )
    )
    Example :
    Code:
    _$ (get:min '((1 6)(2 5)(3 4)))
    (1 4)
    Use (get:min (list a b)) in your case
    Quote Originally Posted by hanhphuc View Post
    $0.02 - 'bounding box' should return min max as well
    Such solutions will not necessarily yield a point on the polyline.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows 8.1
    Discipline
    Landscape
    Using
    AutoCAD 2015
    Join Date
    Apr 2010
    Posts
    3,016

    Default

    What about the coordinates of:

    WHAT ABOUT THIS.PNG

    EDIT: I just realized its too easy for any shape

    pseudo code --> enclosure+crate+adjacent+extension+horizontal <--

    Lisp Code
    Last edited by pBe; 11th Jul 2018 at 07:29 pm.

  8. #8
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    749

    Default

    Quote Originally Posted by Lee Mac View Post
    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
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  9. #9
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows 8.1
    Discipline
    Landscape
    Using
    AutoCAD 2015
    Join Date
    Apr 2010
    Posts
    3,016

    Default

    Quote Originally Posted by hanhphuc View Post
    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. #10
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    749

    Default

    Registered forum members do not see this ad.

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

    Code:
    (defun c:HiLow (/ obj pts) .... )
    BingoBox finally explained doubt thanks
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

Similar Threads

  1. Draw Polyline by list of coordinate
    By amir0914 in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 18th Jul 2017, 09:05 am
  2. Get coordinate of polyline by VBA
    By quangducnguyen in forum .NET, ObjectARX & VBA
    Replies: 10
    Last Post: 31st Oct 2014, 11:45 pm
  3. Point coordinate on Polyline
    By aaryan in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 17th Jul 2012, 07:35 am
  4. Lowest y value - coordinate for a polyline
    By flopo in forum AutoLISP, Visual LISP & DCL
    Replies: 22
    Last Post: 21st Dec 2011, 01:53 pm
  5. Help about coordinate of polyline
    By monkichi in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 11th Dec 2007, 01:10 am

Bookmarks

Posting Permissions

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