Jump to content

Recommended Posts

Posted

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?

Posted
(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)
)

Posted

(setq p1 (getpoint "\nPick 1st point."))

(setq p2 (getpoint "\nPick 2nd point."))

(setq x (distance p1 p2))

Posted

Thank you for the replies

 

seems so somple now :S

Posted

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)))

 

)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...