;;;Elise Moss ;;;www.mossdesigns.com ;;;September 2007 ;;;This routine asks the user to enter two elevations, select two points for distance ;;;and then labels the midpoint of the distance ; Convert value in radians to degrees (defun Radian->Degrees (nbrOfRadians) (* 180.0 (/ nbrOfRadians pi)) ) (defun c:elev-lab () (setq elev1 (getreal "\nEnter first elevation: ")) (setq elev2 (getreal "\nEnter second elevation: ")) (setq pt1 (getpoint "\nSelect first point: ")) (setq pt2 (getpoint pt1 "\nSelect second point: ")) ; calculate distance between the points (setq x-dist (distance pt1 pt2)) ; next calculate the distance between the elevations (setq z-dist (- elev1 elev2)) ;;now get the angle (setq arctan-val (/ z-dist x-dist)) ; this is in radians (setq elev-angle (atan arctan-val)) ; convert radians to degrees (setq degrees-val (Radian->Degrees elev-angle)) ; convert angle to positive number (setq degrees-val (abs degrees-val)) ; convert angle to string (setq degrees-val (rtos degrees-val 2 2)) ; convert distance to string (setq x-dist-string (rtos x-dist 2 2)) ; get degree symbol (setq deg-symb (chr 176)) ;;now we have to construct the text which will be dist < angle (setq elev-text (strcat x-dist-string " LF @ " degrees-val deg-symb)) ; locate midpoint of two points selected (setq x1 (car pt1)) (setq x2 (car pt2)) (setq y1 (cadr pt1)) (setq y2 (cadr pt2)) (setq midx (/ (+ x1 x2) 2)) (setq midy (/ (+ y1 y2) 2)) (setq mid-pt (list midx midy)) ; time to place the text ; need to know if the text has a height defined (setq th-flag (getvar "TXTSIZE")) (if (= th-flag nil) (command "text" "j" "c" mid-pt "" "" elev-text "") ) (if (/= th-flag nil) ; the textsize defined, only need to set rotation (command "text" "j" "c" mid-pt "" elev-text "") ) ) ; end defun