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
(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
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
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
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
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.
(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") ) ) )
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..
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") )
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?
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?