barristann Posted December 29, 2022 Posted December 29, 2022 Hi all, Anyone knows how to modify this code to place a point in between 2 other points in 3D? The below codes belong to PBe and Lee Mac: (defun c:FOO (/ pt1 pt2 mid) (if (and (setq pt1 (getpoint "\n >> Specify first point: ")) (setq pt2 (getpoint "\n >> Specify second point: ")) ) (progn (prompt "\n<< The midpoint is: ") (reverse (cons (/ (+ (last pt1) (last pt2)) 2) (cdr (reverse (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2.0)) ) ) ) ) ) ) ) https://www.cadtutor.net/forum/topic/27359-mid-of-2-points/ Quote
mhupp Posted December 29, 2022 Posted December 29, 2022 (edited) (defun c:FOO (/ pt1 pt2 mid) (if (and (setq pt1 (getpoint "\nSpecify first point: ")) (setq pt2 (getpoint "\nSpecify second point: "))) (progn (setq mid (mapcar '/ (mapcar '+ pt1 pt2) '(2 2 2))) (prompt "\nThe midpoint is: ") (princ mid) ) ) (princ) ) -Edit their is also a snap m2p Edited December 29, 2022 by mhupp Quote
1958 Posted December 29, 2022 Posted December 29, 2022 18 minutes ago, mhupp said: (prompt (strcat "\nThe midpoint is: " mid)) (prompt (strcat "\nThe midpoint is: " (vl-prin1-to-string mid))) 1 Quote
barristann Posted December 29, 2022 Author Posted December 29, 2022 Thank you for your help mhupp. It says: Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended. Quote
barristann Posted December 29, 2022 Author Posted December 29, 2022 Thank you 1958, I'll try your suggestion. Quote
barristann Posted December 29, 2022 Author Posted December 29, 2022 Sorry guys, it still isn't creating a Point in between. I'll keep on trying to see what's wrong Quote
mhupp Posted December 29, 2022 Posted December 29, 2022 (edited) See updated code Specify first point: Specify second point: The midpoint is: (5.84985571613485 4.02541296060991 5.0) Edited December 29, 2022 by mhupp Quote
barristann Posted December 29, 2022 Author Posted December 29, 2022 Hi mhupp, is it possible to create a Point @ that coordinate as well ? Quote
mhupp Posted December 29, 2022 Posted December 29, 2022 (edited) mid is the point (defun c:FOO (/ pt1 pt2 mid) (if (and (setq pt1 (getpoint "\nSpecify first point: ")) (setq pt2 (getpoint "\nSpecify second point: "))) (progn (setq mid (mapcar '/ (mapcar '+ pt1 pt2) '(2 2 2))) (prompt "\nThe midpoint is: ") (princ mid) (entmake (list (cons 0 "POINT") (cons 10 mid))) ) ) (princ) ) Edited December 29, 2022 by mhupp 2 Quote
barristann Posted December 29, 2022 Author Posted December 29, 2022 Yeah, I've tried making PTYPE larger, but I'm still not seeing a Point like below @ that coordinate Quote
mhupp Posted December 29, 2022 Posted December 29, 2022 added entmake to make a point in above code Quote
barristann Posted December 29, 2022 Author Posted December 29, 2022 Amazing! It works! Thank you so much for your help mhupp! 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.