 ; Bracket drawer.
 ; Copyright 1993 by Rocket Software
 ; This code is not commented because I have only a vague idea how it works.
 (DEFUN C:BRAC (/ blip oss pa pk xpa ypa xpk ypk verti horiz radi height angg
                                              p2 p3 p4 p5 p6 p7 p8 p9 p10 p11)
  (setvar "cmdecho" 0)
  (setq blip (getvar "blipmode"))
  (setvar "blipmode" 0)
  (setq oss (getvar "osmode"))
  (setvar "osmode" 0)
  (setq pa (getpoint "Centre point: "))
  (setq pk (getcorner pa "Half outline: "))  ; becomes start point of pline
  (setq xpa (car pa))
  (setq ypa (cadr pa))
  (setq xpk (car pk))
  (setq ypk (cadr pk))
  (setq verti (abs (- ypk ypa)))
  (setq horiz (abs (- xpk xpa)))
  (if (> horiz verti)
      (progn
          (setq radi (/ verti 2))
          (setq height horiz)
          (if (> ypk ypa)
              (progn
                  (setq angg (/ pi 2))
                  (if (> xpk xpa)
                      (setq pk (polar pk (+ angg (/ pi 2)) (* 2 height)))))
              (progn
                  (setq angg (* pi 1.5))
                  (if (< xpk xpa)
                      (setq pk (polar pk (+ angg (/ pi 2)) (* 2 height)))))))
      (progn
          (setq radi (/ horiz 2))
          (setq height verti)
          (if (> xpk xpa)
              (progn
                  (setq angg 0)
                  (if (< ypk ypa)
                      (setq pk (polar pk (+ angg (/ pi 2)) (* 2 height)))))
              (progn
                  (setq angg pi)
                  (if (> ypk ypa)
                      (setq pk (polar pk (+ angg (/ pi 2)) (* 2 height))))))))
  (setq p2 (polar pk (+ angg (* pi 1.5)) radi))  ; centre of first arc
  (setq p3 (polar p2 (+ angg pi) radi))          ; arc end, line start
  (setq p4 (polar p3 (+ angg (* pi 1.5)) (- height (* 2 radi)))) ; line end
  (setq p5 (polar p4 (+ angg pi) radi))          ; 2nd arc centre
  (setq p6 (polar p5 (+ angg (* pi 1.5)) radi))  ; midpoint
  (setq p7 (polar p6 (+ angg (* pi 1.5)) radi))  ; 3rd arc centre
  (setq p8 (polar p7 angg radi))                 ; 3rd arc end, 2nd line start
  (setq p9 (polar p8 (+ angg (* pi 1.5)) (- height (* 2 radi)))) ; line end
  (setq p10 (polar p9 angg radi))                ; 4th arc centre
  (setq p11 (polar p10 (+ angg (* pi 1.5)) radi)); final arc end
  (command "pline" pk "arc" "ce" p2 p3
                      "line" p4
                      "arc" "a" "-90" p6 "a" "-90" p8
                      "line" p9
                      "arc" "ce" p10 p11 "")
  (setvar "blipmode" blip)
  (setvar "osmode" oss)
 (princ))