Jump to content

Lisp to display bearing and distance between two points


surveyscad2018

Recommended Posts

Hi

 

 

I have written a Lisp routine (shown below) that measures the distance between two points, and applies a scale factor that is written within the lisp, and displays it within the command line. Although the lisp functions, it may not be the 'cleanest'. I was wondering if it was possible to add a function to the lisp that in addition to displaying the newly calculated distance, will display a bearing. ideally, the bearing displayed would be written in a Degrees Minutes Seconds format, and not directional bearings (Ex. N73°25'45"W would be displayed as 286°34'15"). In the language of the lisp I have written, from 'x1', North is 0°, and the angle is turned clockwise from north, to a line drawn between 'x1' and 'x2'. Any help would be great. If anyone has a lisp that already does this, or can amend my lisp to do it, that would be perfect.

 

 

Thanks

 

 

Ahmed

 

 

 

 

 

 

;Use this command to measure the distance between two points while applying a Combined Scale Factor
;Be sure to copy this lisp to your job folder, and set your CSF as required. Do not change CSF outside of job folder.
;Ahmed F. 2017
(defun c:DM ()
(setq TD 0)
(setq x1 (getpoint "\nSelect First Point: "))
(setq x2 (getpoint x1 "\nSelect Second Point: "))
(prompt
(strcat
(rtos (distance x1 x2))
(rtos (setq TD (+ TD (/(distance x1 x2) 0.999848))))
)
)
(prompt (strcat "\nTotal Distance = " (rtos TD)))
(princ)
)

 

 

 

 

thanks again.

Edited by SLW210
Added Code Tags!
Link to comment
Share on other sites

Hi ideally, the bearing displayed would be written in a Degrees Minutes Seconds format, and not directional bearings (Ex. N73°25'45"W would be displayed as 286°34'15"..

 

try this

(hp:deg->dms (angle x1 x2))

old thread

Link to comment
Share on other sites

Try this

 

(SETVAR "ANGBASE" (/ pi 2))
(SETVAR "ANGDIR" 1)
(SETVAR "AUNITS" 0)
(while (setq pt1 (getpoint "pt1"))
(setq pt2 (getpoint "pt2"))
(princ "\n")
(princ (angtos (angle pt1 pt2) 1 ))
(princ "\n")
)

Edited by BIGAL
Link to comment
Share on other sites

Hi

 

 

I have written a Lisp routine (shown below) that measures the distance between two points, and applies a scale factor that is written within the lisp, and displays it within the command line. Although the lisp functions, it may not be the 'cleanest'. I was wondering if it was possible to add a function to the lisp that in addition to displaying the newly calculated distance, will display a bearing. ideally, the bearing displayed would be written in a Degrees Minutes Seconds format, and not directional bearings (Ex. N73°25'45"W would be displayed as 286°34'15"). In the language of the lisp I have written, from 'x1', North is 0°, and the angle is turned clockwise from north, to a line drawn between 'x1' and 'x2'. Any help would be great. If anyone has a lisp that already does this, or can amend my lisp to do it, that would be perfect.

 

 

Thanks

 

 

Ahmed

 

 

 

 

 

 

;Use this command to measure the distance between two points while applying a Combined Scale Factor

;Be sure to copy this lisp to your job folder, and set your CSF as required. Do not change CSF outside of job folder.

;Ahmed F. 2017

(defun c:DM ()

(setq TD 0)

(setq x1 (getpoint "\nSelect First Point: "))

(setq x2 (getpoint x1 "\nSelect Second Point: "))

(prompt

(strcat

(rtos (distance x1 x2))

(rtos (setq TD (+ TD (/(distance x1 x2) 0.999848))))

)

)

(prompt (strcat "\nTotal Distance = " (rtos TD)))

(princ)

)

 

 

 

 

thanks again.

 

you can get this lisp from microsurvey

Link to comment
Share on other sites

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