+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23
  1. #1
    Senior Member
    Using
    Map 3D 2008
    Join Date
    Sep 2009
    Posts
    114

    Default Lowest y value - coordinate for a polyline

    Registered forum members do not see this ad.

    Hello,
    How to determine te smaller (and bigger) value,Y or X, for a polyline? I mean the Y coordinate on a polyline where Y has the minimum value for the whole polyline?

  2. #2
    Senior Member
    Computer Details
    JohnM's Computer Details
    Operating System:
    xp pro
    Using
    AutoCAD 2006
    Join Date
    Feb 2009
    Location
    houston, texas
    Posts
    382

    Default

    look at the min and max functions
    also i think there was a post about this awhile back try to search for it

  3. #3
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    This would make a point at the lowest coordinate point of the selected Polyline that has the smallest Y value in it , besides that it would show the Coordinates of the Point which the point lays on .

    Code:
    (vl-load-com)
    (defun c:test (/ ss Coords l i p p1 pt)
      ; Tharwat 15. 06. 2011
      (if (eq (getvar 'pdmode) 0)
        (setvar 'pdmode 3)
      )
      (if
        (setq ss (ssget "_+.:L" '((0 . "*POLYLINE"))))
         (progn
           (setq Coords (vlax-get (vlax-ename->vla-object (ssname ss 0))
                                  'Coordinates
                        )
           )
           (setq l (/ (length Coords) 2))
           (setq i 0
                 p (cons 10 (list (car Coords) (cadr Coords)))
           )
           (repeat l
             (setq
               p1 (cons 10
                        (list (nth i Coords) (nth (setq i (1+ i)) Coords))
                  )
             )
             (if (< (caddr p1) (caddr p))
               (setq p p1)
             )
             (setq i (1+ i))
           )
           (print p)
    
           (entmakex (list (cons 0 "POINT") p))
         )
         (princ)
      )
      (princ)
    )
    Tharwat

  4. #4
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    ???

    *cough* GetBoundingBox *cough*

    Code:
    (defun c:GBB () (c:GetBoundingBox))
    (defun c:GetBoundingBox (/ ss v mn mx)
      (vl-load-com)
      (princ "\rGET BOUNDING BOX \n")
      (if (and (setq ss (ssget ":S:E" ))
               (vlax-method-applicable-p 
                 (setq v (vlax-ename->vla-object (ssname ss 0)))
                 'getboundingbox))
         (progn
           (vla-getboundingbox v 'mn 'mx)
           (princ (mapcar 'vlax-safearray->list (list mn mx))))
         (cond (ss (prompt "\n** GetBoundingBox method not available ** "))
               ((prompt "\n** Nothing selected ** "))))
      (princ))
    Untested - Written quickly on my MacBook from memory.
    Last edited by BlackBox; 15th Jun 2011 at 01:14 pm. Reason: Code correction
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  5. #5
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Hi Renderman .

    The (min max) are functions and you have used them as variables . Is that possible ?

    Code:
    (/ ss v min max)
    Regards.

    Tharwat

  6. #6
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    Quote Originally Posted by Tharwat View Post
    Hi Renderman .

    The (min max) are functions and you have used them as variables . Is that possible ?

    Code:
    (/ ss v min max)
    I noticed that too when I came to work to test (code works BTW).

    Sadly, it was a typo on my part typing code in the forum text box. Code corrected.
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  7. #7
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    No worries mate .

    Best regards.

  8. #8
    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,593

    Default

    Here's some old code I wrote to find the Max/Min points of a curve:

    Code:
    (defun LM:CurveMinMax 
      ( obj fuzz / _GetBoundingBoxWithOffset _GroupByNum _FlattenPoint a acdoc acspc lst obj tmp )
    
      (defun _GetBoundingBoxWithOffset ( obj o / ll ur )
        (
          (lambda ( a )
            (mapcar
              (function
                (lambda ( b )
                  (mapcar
                    (function
                      (lambda ( c ) ((eval c) a))
                    )
                    b
                  )
                )
              )
             '(
                (
                  (lambda ( x ) (- (caar  x) o))
                  (lambda ( x ) (- (cadar x) o))
                )
                (
                  (lambda ( x ) (+ (caadr x) o))
                  (lambda ( x ) (- (cadar x) o))
                )
                (
                  (lambda ( x ) (+ (caadr  x) o))
                  (lambda ( x ) (+ (cadadr x) o))
                )
                (
                  (lambda ( x ) (- (caar   x) o))
                  (lambda ( x ) (+ (cadadr x) o))
                )
              )
            )
          )
          (mapcar 'vlax-safearray->list
            (progn (vla-getboundingbox obj 'll 'ur) (list ll ur))
          )
        )
      )
    
      (defun _GroupByNum ( l n / r)
        (if l
          (cons
            (reverse (repeat n (setq r (cons (car l) r) l (cdr l)) r))
            (_GroupByNum l n)
          )
        )
      )
    
      (defun _FlattenPoint ( p )
        (list (car p) (cadr p) 0.0)
      )
        
      (setq acdoc (vla-get-activedocument (vlax-get-acad-object))
            acspc (vlax-get-property acdoc (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace))
      )  
      (cond
        ( (not (vlax-method-applicable-p obj 'GetBoundingBox))
        )
        ( t
          (setq tmp
            (mapcar
              (function
                (lambda ( x )
                  (apply 'vla-addline (cons acspc (mapcar 'vlax-3D-point x)))
                )
              )
              (_GroupByNum (mapcar '_FlattenPoint (_GetBoundingBoxWithOffset obj (- fuzz))) 2)
            )
          )
          (setq lst
            (mapcar
              (function
                (lambda ( x )
                  (car (_GroupByNum (vlax-invoke obj 'Intersectwith x acExtendOtherEntity) 3))
                )
              )
              tmp
            )
          )
          (mapcar 'vla-delete tmp)
          lst
        )
      )
    )
    
    
    ;; Test Function
    
    (defun c:test( / e m )
      (if
        (and
          (setq e (car (entsel)))
          (setq m (LM:CurveMinMax (vlax-ename->vla-object e) 1e-8))
          (apply 'and m)
        )
        (foreach x m
          (entmakex (list (cons 0 "POINT") (cons 10 x)))
        )
      )
      (princ)
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  9. #9
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,744

    Default

    Quote Originally Posted by Tharwat View Post
    Hi Renderman .

    The (min max) are functions and you have used them as variables . Is that possible ?

    Code:
    (/ ss v min max)
    Regards.

    Tharwat
    It's "possible", since you can redefine anything in Lisp - and since they're localized variables they won't affect enything outside the defun - so the min & max functions wont be removed in other places. Though this is not recommended and would cause a warning message in VLIDE (something like protected symbol redefined).

  10. #10
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by irneb View Post
    (something like protected symbol redefined).
    Thank you .

    I have faced that message before which made me panic for a long time and after searching in that time I have realized the main issue of it , and I doubt I may forget these memories with it and the perfect lesson that I had .

    Regards.

Similar Threads

  1. Get coordinate of polyline by VBA
    By quangducnguyen in forum .NET, ObjectARX & VBA
    Replies: 10
    Last Post: 31st Oct 2014, 11:45 pm
  2. Lowest point of 3D Polyline
    By envirocad in forum Civil 3D & LDD
    Replies: 7
    Last Post: 21st Jun 2010, 08:00 pm
  3. find coordinate of a point at desired distanse of a polyline!!
    By kasra in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 27th Apr 2010, 12:30 am
  4. Help about coordinate of polyline
    By monkichi in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 11th Dec 2007, 01:10 am
  5. Replies: 2
    Last Post: 27th Apr 2007, 08:54 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