Exchange Forum > AutoLISP and Visual LISP
Bearing ~ Distance (revised)
Bearing ~ Distance (revised)

#1

Steveo
Join Date:
03-30-2009
The dsc-rev function is a revision to the dsc.lsp file previously posted in the "Your favorite shortcut function" thread.
This function replaces the "d" for degrees with the degree symbol "°", a simple fix and the text format is what it should be.
Code:
;BEARING ~ DISTANCE
;subst degree symbol for "d"
;SFR 32809
(defun c:dsc-rev (/ p1 p2 d1 a1 mp t1 t2 t3)
  (vl-load-com)
  (setvar "cmdecho" 0)
  (setq p1 (getpoint "First point: "))
  (setq p2 (getpoint "Second point: "))
  (setq d1 (distance p1 p2))
  (setq a1 (angle p1 p2))
  (setq mp (polar p1 a1 (/ d1 2)))
  (setq t1 (angtos a1 0 2))
  (setq t2 (vl-string-subst "°" "d" (angtos a1 4 4)))
  (setq t3 (rtos (/ d1 12) 2 2))
  (if (and (> a1 (* pi 0.5)) (< a1 (* pi 1.5)))
    (setq a1 (angle p2 p1))
  )
  (setvar "textsize" (* (getvar "dimscale") (getvar "dimtxt")))
  (if (= (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))) 0)
    (command "-text" "_mc" mp (getvar "textsize") (rtd a1) (strcat t2 "  ~  " t3 "'"))
    (command "-text" "_mc" mp (rtd a1) (strcat t2 "  ~  " t3 "'"))
  )
  (princ)
)
(defun rtd (rads)
  (* 180.0 (/ rads pi))
)
Bearing ~ Distance (revised)

#2

Joel
Join Date:
09-28-2007
Hi Steveo,
This is exactly what I was needing a few weeks ago with a project I was working on. Your text format change is great!
Thanks,
Joel