
      ; This program is reserved the copyright for Yu-Chia Huang
      ; Shine Long ..
      ; Versin 1.0 June 27, 1989 ; Version 1.1 July 2, 1989

      (defun c:mdim ( )
        (defun setup()
        (setq ch (getstring
         "\n Where will you put the dimension,(R)ight or (B)ottom side? "))
        (setq place (getpoint "\n Choose the location of dimension line : "))
        (setq A (getreal "Enter text height:" ))
        (setq B (getint "Enter number of digits:" ))
        (setq C (getreal "Enter dis from pt to line: "))
        (setq D (getreal "Enter dis from line to dim: "))
        (command "layer" "s" "dim" "")
        (setq px (eval (car place)))
        (setq py (eval (cadr place)))
        (setq base (getpoint "\n Select the base point: "))
        (setq x1 (eval (car base)))
        (setq y1 (eval (cadr base)))
        (if (or (eq ch "R") (eq ch "r")) (right) (bottom))
        )
        (defun right()
           (setq 2nd  (getpoint "\n Pick up the point to set the dimension: "))
           (setq pt2 (osnap 2nd "midp,endp,center,int,node"))
           (setq x2 (eval (car pt2)))
           (setq y2 (eval (cadr pt2)))
           (setq x (- x2 x1))
           (setq y (- y2 y1))
           (setq yval (rtos y 2 B))
           (setq pp  (list px y2))
           (setq pe  (list (+ (car pp) d) y2))
           (setvar "lastpoint" (list (+ x2 C) y2))
           (command "line" "@" pp "")
           (command "text" pe A 0 yval)
           (right)
        )
        (defun bottom()
           (setq 2nd  (getpoint "\n Pick up the point to set the dimension: "))
           (setq pt2 (osnap 2nd "midp,endp,center,int,node"))
           (setq x2 (eval (car pt2)))
           (setq y2 (eval (cadr pt2)))
           (setq x (- x2 x1))
           (setq y (- y2 y1))
           (setq xval (rtos x 2 B))
           (setq pp (list x2 py))
           (setq pe (list x2 (- (cadr pp) d)))
           (setq txt  (list x2 (- py 1)))
           (setvar "lastpoint" (list x2 (- y2 C)))
           (command "line" "@" pp "")
           (command "text" "r" pe A 90 xval)
           (bottom)
        )
        (setup)
      )
