Try this code, not seriously tested though
Code:
;; local defuns
;;--------------------------------------------;;
;; draw text
(defun vk_true_text (txt t0 h ug just / elast)
(setq elast (entlast))
(if (= (cdr (assoc 40 (tblsearch "STYLE" (getvar "TEXTSTYLE")))) 0.0)
(if (/= (strcase just) "L")
(vl-cmdf "_.TEXT" "_J" just t0 h ug txt)
(vl-cmdf "_.TEXT" t0 h ug txt)
) ;_ if
(if (/= (strcase just) "L")
(vl-cmdf "_.TEXT" "_J" just t0 ug txt)
(vl-cmdf "_.TEXT" t0 ug txt)
) ;_ if
) ;_ if
(if (/= elast (entlast))
(entlast)
nil
) ;_ if
)
;;--------------------------------------------;;
; Convert value in radians to degrees
(defun rtd (a)
(* 180.0 (/ a pi))
)
;;------------------------------------- main part ---------------------------------;;
(defun C:BEAR(/ a ang b curth dist elist en ent gkw mp mp2 osm p1 p2 strang strdist txh)
(setq osm (getvar "osmode"))
(setvar "osmode" 0)
(setq curth (getvar "dimtxt"))
(initget 6)
(setq txh (getreal
(strcat "\nEnter the text height <" (rtos curth) ">: ")
)
)
(cond ((not txh) (setq txh curth)))
(initget 1 "Select Enter")
(setq gkw (getkword
"\nSelect line or Enter two points (Select/Enter) <S>: "
)
)
(if (eq "Select" gkw)
(progn
(setq ent (entsel "\nSelect line: "))
(setq en (car ent))
(setq elist (entget en))
(setq p1 (cdr (assoc 10 elist))
p2 (cdr (assoc 11 elist))
mp (mapcar '(lambda (a b) (/ (+ a b) 2)) p1 p2)
ang (angle p1 p2)
dist (distance p1 p2)
strdist (rtos dist 2 3)
strang (angtos ang 0 2)
)
(if (< (/ pi 2) ang (* pi 1.5))
(setq ang (+ pi ang))
)
(setq mp2 (polar mp (- ang (/ pi 2)) txh)
mp (polar mp (+ (/ pi 2) ang) (/ txh 2))
)
(vk_true_text strdist mp txh (rtd ang) "BC")
(vk_true_text strang mp2 txh (rtd ang) "TC")
)
(progn
(setq p1 (getpoint "\nSpecify a first point: "))
(setq p2 (getpoint p1 "\nSpecify a second point: "))
(setq mp (mapcar '(lambda (a b) (/ (+ a b) 2)) p1 p2)
ang (angle p1 p2)
dist (distance p1 p2)
strdist (rtos dist 2 3)
strang (angtos ang 0 2)
)
(if (< (/ pi 2) ang (* pi 1.5))
(setq ang (+ pi ang))
)
(setq mp2 (polar mp (- ang (/ pi 2)) txh)
mp (polar mp (+ (/ pi 2) ang) (/ txh 2))
)
(vk_true_text strdist mp txh (rtd ang) "BC")
(vk_true_text strang mp2 txh (rtd ang) "TC")
)
)
(setvar "osmode" osm)
(princ)
)
(prompt "\nType BEAR to start command")
(prin1)
~'J'~