;3DCABNT.LSP - WRITTEN BY JAN TAYLOR 
;              FOR AUTOLISP CLASS DR238
;              BILLINGS VOCATIONAL TECHNICAL CENTER
;              BILLINGS, MONTANA
;              FEBRUARY 20, 1991
;THIS PROGRAM WILL DRAW A CABINET GIVEN THE WIDTH, HEIGHT, DEPTH, 
;THICKNESS OF MATERIAL USED, COUNTERTOP OVERHANG, THICKNESS OF COUNTERTOP, AND 
;HEIGHT OF THE SHELF. THIS PROGRAM WILL ALSO SET A "CABINET" LAYER AT THE 
;BEGINNING.  SIMPLY PICK THE BEGINNING POINT AND ANSWER THE QUESTIONS 
;AND WAA-LAA!-CABINETS!!! 
;IF YOU INTEND TO USE THIS PROGRAM FOR WALL CABINETS, BE SURE TO USE "0" FOR 
;THICKNESS OF COUNTERTOP AND COUNTERTOP OVERHANG.
;
;NOTE: The DTR and RTD functions must be defined in your ACAD.LSP program
;
;Send comments to Compuserve Account #76264,2273
;*****************************************************************************
(defun dtr (a)
  (* pi (/ a 180.00))
)
(defun rtd (a)
  (/ (* a 180.00) pi)
)
(DEFUN C:3DCABNT ()
(GRAPHSCR)
(SETVAR "CMDECHO" 0)
(SETVAR "BLIPMODE" 0)
(SETQ P1 (GETPOINT "\nPICK THE LOWER LEFT-HAND SIDE OF THE CABINET: "))
(SETQ W (GETDIST "\nWHAT IS THE WIDTH OF THE CABINET?: "))
(SETQ D (GETDIST "\nWHAT IS THE DEPTH OF THE CABINET?: "))
(SETQ H (GETDIST "\nWHAT IS THE HEIGHT OF THE CABINET?: "))
(SETQ OH (GETDIST "\nHOW MUCH OVERHANG DO YOU WANT?: "))
(SETQ T (GETDIST "\nWHAT IS THE THICKNESS OF THE MATERIAL USED?: "))
(SETQ CT (GETDIST "\nWHAT IS THE THICKNESS OF THE COUNTER TOP?: "))
(SETQ S (GETDIST "\nWHAT IS THE HEIGHT OF THE FIRST SHELF?: "))
     (COMMAND "LAYER" "M" "CABINET" "" "")
     (SETQ P2 (POLAR P1 (DTR 0) W))
     (SETQ P3 (POLAR P2 (DTR 90) D))
     (SETQ P4 (POLAR P1 (DTR 90) D))
     (SETQ P5 (LIST (CAR P1) (CADR P1) H))
     (SETQ P6 (POLAR P5 (DTR 0) W))
     (SETQ P7 (POLAR P6 (DTR 90) D))
     (SETQ P8 (POLAR P5 (DTR 90) D))
(SETQ P9 (LIST (+ (CAR P1) T) (CADR P1) (+ (CADDR P1) T)))
(SETQ P10 (LIST (- (CAR P2) T) (CADR P2) (+ (CADDR P2) T)))
(SETQ P11 (LIST (- (CAR P3) T) (CADR P3) (+ (CADDR P3) T)))
(SETQ P12 (LIST (+ (CAR P4) T) (CADR P4) (+ (CADDR P4) T)))
(SETQ P14 (LIST (CAR P10) (CADR P10) (- H T)))
(SETQ P13 (LIST (CAR P9) (CADR P9) (- H T)))
(SETQ P15 (LIST (CAR P11) (CADR P11) (- H T)))
(SETQ P16 (LIST (CAR P12) (CADR P12) (- H T)))
             (COMMAND "3DFACE" P1 P5 P8 P4 "")
             (COMMAND "3DFACE" P2 P6 P7 P3 "")
             (COMMAND "3DFACE" P5 P6 P7 P8 "")
             (COMMAND "3DFACE" P1 P2 P3 P4 "")
             (COMMAND "3DFACE" P9 P10 P11 P12 "")
             (COMMAND "3DFACE" P10 P11 P15 P14 "")
             (COMMAND "3DFACE" P9 P12 P16 P13 "")
             (COMMAND "3DFACE" P13 P14 P15 P16 "")
             (COMMAND "3DFACE" P1 P9 P13 P5 "")
             (COMMAND "3DFACE" P1 P9 P10 P2 "")
             (COMMAND "3DFACE" P2 P10 P14 P6 "")
             (COMMAND "3DFACE" P6 P14 P13 P5 "")
(SETQ P17 (LIST (CAR P9) (CADR P9) S))
(SETQ P18 (LIST (CAR P10) (CADR P10) S))
(SETQ P19 (LIST (CAR P11) (CADR P11) S))
(SETQ P20 (LIST (CAR P12) (CADR P12) S))
             (COMMAND "3DFACE" P17 P18 P19 P20 "")
(SETQ P21 (LIST (CAR P17) (CADR P17) (- (CADDR P17) T)))
(SETQ P22 (LIST (CAR P18) (CADR P18) (- (CADDR P18) T)))
(SETQ P23 (LIST (CAR P20) (CADR P20) (- (CADDR P20) T)))
(SETQ P24 (LIST (CAR P19) (CADR P19) (- (CADDR P19) T)))
             (COMMAND "3DFACE" P21 P22 P24 P23 "")
             (COMMAND "3DFACE" P17 P18 P22 P21 "")
(SETQ P25 (LIST (CAR P6) (- (CADR P6) OH) (CADDR P6)))
(SETQ P26 (LIST (CAR P25) (CADR P25) (+ (CADDR P25) CT)))
(SETQ P27 (LIST (CAR P5) (- (CADR P5) OH) (+ (CADDR P5) CT)))
(SETQ P28 (LIST (CAR P27) (CADR P27) (- (CADDR P27) CT)))
             (COMMAND "3DFACE" P25 P26 P27 P28 "")
(SETQ P29 (LIST (CAR P7) (CADR P7) (+ (CADDR P7) CT)))
(SETQ P30 (LIST (CAR P8) (CADR P7) (+ (CADDR P8) CT)))
             (COMMAND "3DFACE" P25 P26 P29 P7 "")
             (COMMAND "3DFACE" P7 P29 P30 P8 "")
             (COMMAND "3DFACE" P8 P30 P27 P28 "")
             (COMMAND "3DFACE" P27 P26 P29 P30 "")
             (COMMAND "3DFACE" P5 P28 P25 P6 "")
(SETQ P31 (LIST (- (CAR P2) (/ T 2)) (CADR P2) (+ (CADDR P2) (/ T 2))))
(SETQ P32 (LIST (CAR P31) (CADR P31) (+ (CADDR P31) (- H (/ T 2)))))
(SETQ P33 (LIST (+ (CAR P5) (/ T 2)) (CADR P5) (+ (CADDR P32) (/ T 2))))
(SETQ P34 (LIST (CAR P33) (CADR P33) (+ (CADDR P1) (/ T 2))))
             (COMMAND "3DFACE" P31 P32 P33 P34 "")
(SETQ P35 (LIST (CAR P31) (- (CADR P31) T) (CADDR P31)))
(SETQ P36 (LIST (CAR P32) (- (CADR P32) T) (CADDR P32)))
(SETQ P37 (LIST (CAR P33) (- (CADR P33) T) (CADDR P33)))
(SETQ P38 (LIST (CAR P34) (- (CADR P34) T) (CADDR P34)))
             (COMMAND "3DFACE" P35 P36 P37 P38 "")
             (COMMAND "3DFACE" P35 P31 P32 P36 "")
             (COMMAND "3DFACE" P32 P36 P37 P33 "")
             (COMMAND "3DFACE" P33 P37 P38 P34 "")
             (COMMAND "3DFACE" P34 P38 P35 P31 "")
(SETVAR "BLIPMODE" 1)
)
