I have a LSP file that's been in my library for a while that allows you to pick any two points then list the bearing/horizontal/slope distance in the command line. Don't remember where I got it - but it is currently set to report the final distances to two (2) decimal places. Hoping there is an easy way to modify to have it read distance to four (4) decimal places?
This is probably super simple to anyone comfortable writing LSP...I'm just not there....
Alternatively - if this pulls from a variable or setting that would control that rather than the LSP code itself, what would I use to do that?
Code:
(defun C:INV ( / 2DIST fact str1 tw CNTR PT1 PT2 ang DST PDST Pang)
(defun 2DIST (PT)
(list (car pt)(cadr pt))
) ;defun
(setq fact nil)
(if(and(= 1 (getvar "cvport"))(trans '(1 0 0) 2 3 0))
(progn
(setq fact (car (trans '(1 0 0) 2 3 0)))
(princ "\nPS:MS == 1:")
(princ(/ 1 fact))
(command "mspace")
(setq tw (- (* 2 pi)(cdr(assoc 51(entget(acet-currentviewport-ename))))))
(command "pspace")
)
)
(setq CNTR 0 ;INITIALIZE COUNTER
PT1 (getpoint "\nPick First Point") ;PROMPT FOR FIRST POINT
PT2 PT1
)
(while PT2 ;IF YES OR ENTER
(setq PT2 (getpoint "\nPick Next Point" PT1)) ;PROMPT FOR NEXT POINT
(if PT2
(progn
(if fact
(progn
(setq DST (/ (distance (2DIST PT1)(2DIST PT2))fact) ;CONVERT TO STRING
PDST (distance (2DIST PT1)(2DIST PT2)) ;CONVERT TO STRING
CNTR (1+ CNTR) ;ADD TO COUNTER FOR COLOR CHANGE
Pang (angtos (angle pt1 pt2)4 4)
ang (angtos (+(angle pt1 pt2)tw)4 4)
deltaz (/ (- (car(cddr pt2)) (car(cddr pt1)))fact)
slope (/ deltaz DST)
)
(if(eq Pang ang)
(setq DST(strcat "MS Bearing= "ang ", Dist= " (rtos DST 2 2) "', PS Dist= " (rtos PDST 2 2) "\""))
(setq DST(strcat "MS Bearing= "ang ", Dist= " (rtos DST 2 2) "', PS Bearing= "Pang ", Dist= " (rtos PDST 2 2) "\""))
);if
);progn
(setq DST (distance (2DIST PT1)(2DIST PT2))
CNTR (1+ CNTR)
ang (angtos (angle pt1 pt2)4 4)
deltaz (- (car(cddr pt2)) (car(cddr pt1)))
slope (/ deltaz DST)
DST (strcat "Bearing= "ang ", Dist= " (rtos DST 2 2) "'")
)
);if fact
(prompt (strcat "\n" DST)) ;Print the distance to command line
(if (/= 0 deltaz)(prompt (strcat "\nDelta elev= "(rtos deltaz) " Slope= "(rtos slope 2 6))))
(grtext -1 DST) ;Print distance in status line
(grdraw PT1 PT2 CNTR 2) ;Draw a colored line between points
(setq PT1 PT2) ;Change start point
) ;end progn
) ;end if PT2
) ;end while PT2
(grtext -1 "") ;Clear status line
(princ)
) ;end fun