;;;*THIS PARAMETRIC ROUTINE DRAWS WINDOWS
;;;*Written by K. Ramage February 1995.
;;;*--------------------------------------------------------
(defun C:WINDOW ( / IP THK ANG L P1 P2 P3 P4 P5 P6 P7 P8 P9
                    P10 P11 P12 P13 P14) 
;;;*----------------------------------------------------------
;;;*INITIALISE
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (vla-startundomark doc)
        (initerr)
        (setvar "CMDECHO" 0)
        (setvar "BLIPMODE" 0)
        (setvar "OSMODE" OLDSNAP)
;;;*----------------------------------------------------------
     (initget 1)
     (setq IP (getpoint "\nInsertion Point : ")
          P11 (getpoint IP "\nWall Thickness : ")
     );setq
     (setvar "OSMODE" 0)
     ;(setvar "PICKBOX" 0)
     (setq ANG (angle IP P11)
           ANG (RTD ANG)
           ANG (+ ANG 90.0)
           THK (distance IP P11)
             L (getreal "\nLength of Window : ")
           P1 (polar IP (DTR (+ ANG 180.0)) (/ L 2))
           P2 (polar P1 (DTR (+ ANG 270.0)) (+ THK 0.0))
           P3 (polar P2 (DTR ANG) L)
           P4 (polar P3 (DTR (+ ANG 90.0)) (+ THK 0.0))
           P5 (polar P1 (DTR (+ ANG 270.0)) (/ THK 2))
           P6 (polar P5 (DTR (+ ANG 90.0)) (/ THK 6))
           P7 (polar P6 (DTR (+ ANG 270.0)) (/ THK 4))
           P8 (polar P5 (DTR ANG) L)
           P9 (polar P6 (DTR ANG) L)
          P10 (polar P7 (DTR ANG) L)
          P12 (polar P11 (DTR (+ ANG 180.0)) (/ L 2))
          P13 (polar P11 (DTR ANG) (/ L 2))
          P14 (polar P11 (DTR ANG) 100.0)
    );setq

      (command "_pLINE" P1 P2 P3 P4 "_c"
               "_LINE" P6 P9 ""
               "_LINE" P7 P10 ""
               ;"_BREAK" P14 "_F" P12 P13
               ;"_ERASE" P11 ""
      );command
  (vla-endundomark doc)
;;;*RESET ENVIROMENT
   (reset)
   (princ)
);defun C:WINT
;;;*==========================================================
(defun initerr ()
  (setq oldlayer (getvar "clayer"))
  (setq oldsnap (getvar "osmode"))
  (setq oldpick (getvar "pickbox"))
  (setq temperr *error*)
  (setq *error* trap)
  (princ)
)					;defun
;;;*===========================================================
(defun trap (errmsg)
  (command nil nil nil)
  (if (not (member errmsg '("console _BREAK" "Function Cancelled"))
      )
    (princ (strcat "\nError: " errmsg))
  )					;                 
  (setvar "clayer" oldlayer)
  (setvar "BLIPMODE" 0)
  (setvar "menuecho" 0)
  (setvar "highlight" 1)
  (setvar "osmode" oldsnap)
  (setvar "pickbox" oldpick)
  (princ "\nError Resetting Enviroment ")
  (terpri)
  (setq *error* temperr)
  (princ)
)					;defun
;;;*===========================================================
(defun reset ()
  (setq *error* temperr)
  (setvar "clayer" oldlayer)
  (setvar "BLIPMODE" 0)
  (setvar "menuecho" 0)
  (setvar "highlight" 1)
  (setvar "osmode" oldsnap)
  (setvar "pickbox" oldpick)
  (princ)
)					;defun
;;;*======================================================
;*-----------------------------------------------------------------------------
;*dtr converts degrees to radians
(defun dtr (a)
 (* pi (/ a 180))
);defun
;*-----------------------------------------------------------------------------
;*rtd converts radians to degrees
(defun rtd (a)
 (/ (* a 180) pi)
);defun
;*-----------------------------------------------------------------------------
(princ)
               

(defun C:WINDOW1460 ( / IP THK ANG L P1 P2 P3 P4 P5 P6 P7 P8 P9
                    P10 P11 P12 P13 P14) 
;;;*----------------------------------------------------------
;;;*INITIALISE
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (vla-startundomark doc)
        (initerr)
        (setvar "CMDECHO" 0)
        (setvar "BLIPMODE" 0)
        (setvar "OSMODE" OLDSNAP)
;;;*----------------------------------------------------------
     (initget 1)
     (setq IP (getpoint "\nInsertion Point : ")
          P11 (getpoint IP "\nWall Thickness : ")
     );setq
     (setvar "OSMODE" 0)
     ;(setvar "PICKBOX" 0)
     (setq ANG (angle IP P11)
           ANG (RTD ANG)
           ANG (+ ANG 90.0)
           THK (distance IP P11)
             L 1460
           P1 (polar IP (DTR (+ ANG 180.0)) (/ L 2))
           P2 (polar P1 (DTR (+ ANG 270.0)) (+ THK 0.0))
           P3 (polar P2 (DTR ANG) L)
           P4 (polar P3 (DTR (+ ANG 90.0)) (+ THK 0.0))
           P5 (polar P1 (DTR (+ ANG 270.0)) (/ THK 2))
           P6 (polar P5 (DTR (+ ANG 90.0)) (/ THK 6))
           P7 (polar P6 (DTR (+ ANG 270.0)) (/ THK 4))
           P8 (polar P5 (DTR ANG) L)
           P9 (polar P6 (DTR ANG) L)
          P10 (polar P7 (DTR ANG) L)
          P12 (polar P11 (DTR (+ ANG 180.0)) (/ L 2))
          P13 (polar P11 (DTR ANG) (/ L 2))
          P14 (polar P11 (DTR ANG) 100.0)
    );setq

      (command "_pLINE" P1 P2 P3 P4 "_c"
               "_LINE" P6 P9 ""
               "_LINE" P7 P10 ""
               ;"_BREAK" P14 "_F" P12 P13
               ;"_ERASE" P11 ""
      );command
  (vla-endundomark doc)
;;;*RESET ENVIROMENT
   (reset)
   (princ)
);defun