mid point of x, y

Discussion in 'AutoCAD' started by JonBaker, Apr 28, 2004.

  1. JonBaker

    JonBaker Guest

    I need to know how to extract the x and y values of "getpoint" so I can get the mid point between to picked points..


    --
    Jonathan J. Baker
    Carroll & Lange, Inc.
    Professional Engineers & Land Surveyors
    Lakewood, Colorado
     
    JonBaker, Apr 28, 2004
    #1
  2. (setq pt1 (getpoint "\nPick Start: "))
    (setq pt2 (getpoint "\nPick End: "))
    (setq mid (list
    (/ (+ (car pt1) (car pt2)) 2)
    (/ (+ (cadr pt1) (cadr pt2)) 2)
    (/ (+ (caddr pt1) (caddr pt2)) 2)
    )
    )

    ;;; Not tested - just off the top of my head

    --
    Darren J. Young
    CAD/CAM Systems Developer

    Cold Spring Granite Company
    202 South Third Avenue
    Cold Spring, Minnesota 56320

    Email:
    Phone: (320) 685-5045
    Fax: (320) 685-5052
     
    Darren J. Young, Apr 28, 2004
    #2
  3. JonBaker

    JonBaker Guest

    thanx I'll try that..

    oh and where did my post show up?



    get the mid point between to picked points..
     
    JonBaker, Apr 28, 2004
    #3
  4. JonBaker

    Rudy Tovar Guest

    Here's an example of getting the box, use it as an example.

    (setq p1 (getpoint "\nPick Lower Left Corner: "))
    (if p1
    (progn
    (setq p3 (getcorner p1 "\nPick Upper Right Corner: "))
    (if p3
    (progn
    (setq p2 (list (car p3)(cadr p1))
    p4 (list (car p1)(cadr p3))
    )
    )
    )
    )
    )

    The midpoint between two points would be,

    (setq p1 (getpoint))
    (setq p2 (getpoint))
    (setq m (polar p1 (angle p1 p2) (/ (distance p1 p2) 2)))

    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Apr 28, 2004
    #4
  5. JonBaker

    Rudy Tovar Guest

    Also, remember that if you want to use the rubberband effect to declare p1
    in (setq p2 (getpoint p1 "\nNext point: "))
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi


     
    Rudy Tovar, Apr 28, 2004
    #5
  6. JonBaker

    devitg Guest

    Do you know the geom-calc tool ????

    see the following code

    (if (= cal nil) ; if not loaded
    (arxload "geomcal") ;it load
    ) ;_if it s load ok


    (setq p1 (getpoint "first point"))
    (setq p2 (getpoint" second point "))
    (setq factor 0.5)
    (SETQ midpoint (C:CAL "plt (p1,p2,factor)"))
    (command "_circle" midpoint factor)

    You can change FACTOR to any value you want , even a greater than one to locate it far from P2 or a negative to locate it before P1

    GEOMCAL , is a useful tool , and let you not to do so much calc.

    You can see it on the plain ACAD help
     
    devitg, Apr 29, 2004
    #6
  7. JonBaker

    John Uhden Guest

    Rudy:

    Let's not forget the possibility of Z values...
    (defun midpoint (p1 p2)
    (mapcar '* '(0.5 0.5 0.5) (mapcar '+ p1 p2))
    )

    But it will work with 2D points as well, or a mixture thereof.
     
    John Uhden, Apr 29, 2004
    #7
  8. JonBaker

    Rudy Tovar Guest

    How many licks does it take, to get to the center of a tootsie pop?

    The world may never know...

     
    Rudy Tovar, Apr 29, 2004
    #8
  9. JonBaker

    OLD-CADaver Guest

    (defun midpt ()
    (if (= cal nil)
    (arxload "geomcal")
    (progn
    (setq pt1 (getpoint "\n Select First Point for Midway Calculation")
    pt2 (getpoint "\n Select Second Point for Midway Calculation"))
    (cal "(pt1+pt2) /2")
    )
    )
    )
     
    OLD-CADaver, Apr 29, 2004
    #9
  10. JonBaker

    JonBaker Guest

    thank you everyone.. I will give most of these a whirl and see what I get..

    --

    Jonathan J. Baker
    Carroll & Lange, Inc.
    Professional Engineers & Land Surveyors
    Lakewood, Colorado
    ~~~~~~~~~~~~

    get the mid point between to picked points..
     
    JonBaker, Apr 29, 2004
    #10
  11. JonBaker

    randy benson Guest

    Misplaced paren (returns an error the first time it's run if "geomcal" is
    not already loaded); try --->

    (defun midpt ( / pt1 pt2)
    (if (= cal nil)
    (arxload "geomcal")
    )
    (setq pt1 (getpoint "\n Select First Point for Midway Calculation")
    pt2 (getpoint pt1 "\n Select Second Point for Midway Calculation")
    )
    (cal "(pt1+pt2) /2")
    )
     
    randy benson, May 2, 2004
    #11
  12. JonBaker

    OLD-CADaver Guest

    hmmm... I can see where yours is a little cleaner, but the other has been working fine for us for 5 or 6 years. What version of AutoCAD are you using?
     
    OLD-CADaver, May 3, 2004
    #12
  13. JonBaker

    randy benson Guest

    Just updated to ALD2005, but I think when I responded I was still using
    ALD2004.

    But the way I read the original routine, if geomcal is not loaded, arxload
    is called and the routine is finished -- even if it didn't return an error,
    the progn wouldn't get called. N'cest pas?

    working fine for us for 5 or 6 years. What version of AutoCAD are you
    using?
     
    randy benson, May 4, 2004
    #13
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.