FazBear Posted September 30, 2008 Share Posted September 30, 2008 hi all I am a bit of a newbie where lisp is involved, all i need to do is write the x distance between 2 points to a variable. can anyone help? Quote Link to comment Share on other sites More sharing options...
lpseifert Posted September 30, 2008 Share Posted September 30, 2008 (defun c:test () (setq p1 (getpoint "Pick first point: ") p1x (car p1) p2x (car (getpoint "Pick second point: " p1)) xdist (abs (- p1x p2x)) ) (alert (strcat "The X distance between the two points is " (rtos xdist 2 2) "\nand is saved in the variable Xdist")) (princ) ) Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 30, 2008 Share Posted September 30, 2008 Or (setq dist(getdist)) Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 30, 2008 Share Posted September 30, 2008 Excuse me. There isn't X distance. Quote Link to comment Share on other sites More sharing options...
CAB Posted October 1, 2008 Share Posted October 1, 2008 (setq p1 (getpoint "\nPick 1st point.")) (setq p2 (getpoint "\nPick 2nd point.")) (setq x (distance p1 p2)) Quote Link to comment Share on other sites More sharing options...
FazBear Posted October 1, 2008 Author Share Posted October 1, 2008 Thank you for the replies seems so somple now :S Quote Link to comment Share on other sites More sharing options...
FazBear Posted October 1, 2008 Author Share Posted October 1, 2008 Ended up using ASMI's method, just tweaked it to a more simple format (for me to understand). Thanks again! (defun c:signage () (setq POINT1 (getpoint "Pick Top Left: ")) (setq POINT2 (getpoint POINT1 "Pick Bottom Right Corner: ")) (setq POINT1X (car POINT1)) (setq POINT2X (car POINT2)) (setq XDIST (- POINT2X POINT1X)) (setq POINT1Y (cadr POINT1)) (setq POINT2Y (cadr POINT2)) (setq YDIST (- POINT1Y POINT2Y)) (alert (strcat "The X distance between the two points is "(rtos XDIST 2 2) "\nThe Y distance between the two points is "(rtos YDIST 2 2))) ) Quote Link to comment Share on other sites More sharing options...
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.