; -----------------------------------------------------
; Die Layergruppe R- muss vorhanden sein 14.6.92/4.8.97
; Waende zeichnen - LAYER R-6
; Tuer   zeichnen - LAYER R-3
; -----------------------------------------------------
(Defun C:Wand ()
  (Setvar "Cmdecho" 0)
  (Initget "2 S M E")
  (Setq B (Getkword "\nGenerate wall - 2 Spaces/Middleline/<Edge>: "))
  (If (= nil B)(Setq B "E"))
  (If (Or (= B "E") (= B "M"))  
    (Progn
      (Prompt "\nThickness of the wall <")
      (Princ (Rtos (Getvar "Userr1") 2 3))
      (Initget 6)
      (Setq A (Getdist ">: "))
      (If (= nil A)
        (Setq A (Getvar "Userr1"))
      )
      (Setvar "Userr1" A)
    )
    (Progn
      (Initget 7)
      (Setq A1 (Getdist "\n1st distance: "))
      (Initget 7)
      (Setq A2 (Getdist "\n2nd distance: "))
    )
  )
  (Initget 1)
  (Setq P1 (Getpoint "\nfrom point: "))
  (Initget 1)
  (Setq P2 (Getpoint P1 "\nto point: "))
  (Command "_PLINE" P1 P2)
  (Setq P4 t)
  (While
    (Boundp 'P4)
      (Initget "U C")
      (Setq P4 
        (Getpoint (Getvar "Lastpoint") "\nUndo/Close/<to point>: "))
      (Cond
        ((= nil P4)
          (Command "")
        )
        ((= "C" P4)
          (Command "_close")
          (Setq P4 nil)
        )
        ((= "U" P4)
          (Command "_undo")
        )
        ((= 'LIST (Type P4))
          (Command P4)
        )
      )
  )
  (Cond
    ((= B "E")
      (Setq E2 (Entlast))
      (Setq P2 (Getpoint "\nOn which side is the wall ?"))
      (Command "_offset" A P1 P2 "")
      (Setq E3 (Entlast))
    )
    ((= B "M")
      (Setq E1 (Entlast))
      (Command "_select" "_L" "")
      (Command "_offset" (/ A 2)
        (Polar P1 (Angle P1 P2) (/ (Distance P1 P2) 2))
        (Polar (Getvar "Lastpoint") (+ (/ Pi 2) (Angle P1 P2)) (/ A 2)) "")
      (Setq E2 (Entlast))
      (Command "_offset" A (Getvar "Lastpoint")
        (Polar (Getvar "Lastpoint") (+ (/ Pi 2) (Angle P2 P1)) A) "")
      (Setq E3 (Entlast))
    )
    ((or (= B "S") (= B "2"))
      (Setq E1 (Entlast))
      (Command "_select" "_L" "")
      (Prompt "\n(1)On which side ")
      (Princ (Rtos A1 2 4))
      (Setq P2 (Getpoint " will be cleared ?: "))
      (Command "_offset" A1 P1 P2 "")
      (Setq E2 (Entlast))
      (Prompt "\n(2)On which side ")
      (Princ (Rtos A2 2 4))
      (Setq P2 (Getpoint " will be cleared ?: "))
      (Command "_offset" A2 P1 P2 "")
      (Setq E3 (Entlast))
    )
  )
  (If
    (Or (= B "2") (= B "S") (= B "M"))
      (Progn
        (Prompt "\nMiddleline will be ")
        (Initget "D P O")
        (Setq A (Getkword "\n<D>eleted/<P>reserve/<On R-6>: "))
        (Cond
          ((= A "D")
            (Command "_erase" "_p" "")
          )
          ((Or (= A "O") (= A "P") (= A nil))
            (Command "_change" "_p" "" "_p" "_la" "R-6" "")
          )
        )
      )
  )
  (Initget "Y N")
  (Setq A (Getkword
    "\nWalls are POLYLINES. Transform to LINE? <Y>: "))
  (If
    (Or (= A "Y") (= A nil))
      (Command "_explode" E2 "_explode" E3 "_explode" E1 ^C)
  )
  (Princ)
)
; ----------------ENDE WAND --------------------------

; ---------------------------------
; Durchbrueche zeichnen - LAYER R-6
;---------------------------------
(Defun C:DURCHBRUCH ()
  (Setvar "Cmdecho" 0)
  (Initget 7)
  (Setq A (Getdist "\nWidth of break: "))
	(Initget 1)
	(setvar "osmode" 512)
	(Setq P1 (Getpoint "\n1st point: "))
	(Setvar "Lastpoint" P1)
	(Initget 1)
	(setvar "osmode" 128)
	(Setq P2 (Getpoint "\nOpposite side of wall: "))
	(Initget 1)
	(setvar "osmode" 512)
	(Setq P3 (Getpoint "\nOn which side is the break:"))
	(setvar "osmode" 0)
	(Setq A1 (Angle P1 P3))
	(Setq P3 (Polar P1 A1 A))
	(Setq A2 (Angle P1 P2))
	(Setq P4 (Polar P3 A2 (Distance P1 P2)))
	(Command "_break" P1 "_f" P1 P3 "_break" P2 "_f" P2 P4)
	(Command "_line" P1 P2 "" "_line" P3 P4 "")
	(Princ)
)
; ------------------- ENDE Durchbruch ---------------------------

; --------------------------
; Tuer zeichnen - LAYER R-3
; --------------------------
(Defun C:TUER ()
	(Setvar "Cmdecho" 0)
	(Initget 7)
	(Setq A (Getdist "\nWidth of the door: "))
	(Initget 1)
	(Setq P1 (Osnap (getpoint "\Rotation point: ") "_nea"))
	(Setvar "Lastpoint" P1)
	(Initget 1)
	(Setq P2 (Osnap (Getpoint "\nOpposite side of the wall: ") "_per"))
	(Initget 1)
	(setvar "osmode" 512)
	(Setq P3 (Getpoint "\nOn which side is the door: "))
	(setvar "osmode" 0)
	(Setq A1 (Angle P1 P3))
	(Setq P3 (Polar P1 A1 A))
	(Setq A2 (Angle P1 P2))
	(Setq P4 (Polar P3 A2 (Distance P1 P2)))
	(Setq P5 (Polar P1 (+ Pi A2) A))
	(Command "_break" P1 "_f" P1 P3 "_break" P2 "_f" P2 P4)
	(Command "_line" P1 P2 "" "_line" P3 P4 "" "_line" P1 P5 "")
	(Command "_arc" P3 "_e" P5 "_A" 90)
	(Princ)
)

; ---------------------------------
; Doppel-Tuer zeichnen - LAYER R-3
; ---------------------------------
(Defun C:DTUER ()
	(Setvar "Cmdecho" 0)
	(Initget 7)
	(Setq A (/ (Getdist "\nDouble door width: ") 2)) ; eingegeb. Abstand
                                             ; halbieren
	(Initget 1)
	(setvar "osmode" 512)
	(Setq P1 (getpoint "\nRotation point: "))
	(Setvar "Lastpoint" P1)
	(Initget 1)
	(setvar "osmode" 128)
	(Setq P2 (Getpoint "\nOpposite side of the wall: "))
	(Initget 1)
	(setvar "osmode" 512)
	(Setq P3 (Getpoint "\nOn which side is the double door: "))
	(setvar "osmode" 0)
	(Setq A1 (Angle P1 P3))
	(Setq P3 (Polar P1 A1 A))
	(Setq A2 (Angle P1 P2))
	(Setq P4 (Polar P3 A2 (Distance P1 P2)))
	(Setq P5 (Polar P1 (+ Pi A2) A))
	(Setq P6 (Polar P3 A1 A))
	(Setq P7 (Polar P4 A1 A))
	(Setq P8 (Polar P6 (+ Pi A2) A))
	(Command "_break" P1 "_f" P1 P6 "_break" P2 "_f" P2 P7)
	(Command "_line" P1 P2 "" "_line" P6 P7 "" "_line" P1 P5 "" "_line" P6 P8 "")
	(Command "_arc" P3 "_e" P5 "_a" 90)
	(Command "_arc" P8 "_e" P3 "_a" 90)
	(Princ)
)

; ---------------------------------------------------
; Fenster - LAYER R-3
; Tor     - LAYER R-7
; die Layer werden ausserhalb des Makros eingestellt
; ----------------------------------------------------
(Defun C:fenstor ()
	(Setvar "Cmdecho" 0)
	(Initget 7)
	(Setq A (Getdist "\nWidth of the window/gate: "))
	(Initget 1)
	(setvar "osmode" 512)
	(Setq P1 (getpoint "\n1st point: "))
	(Setvar "Lastpoint" P1)
	(Initget 1)
	(setvar "osmode" 128)
	(Setq P2 (Getpoint "\nOpposite side of the wall: "))
	(Initget 1)
	(setvar "osmode" 512)
	(Setq P3 (Getpoint "\nOn which side is the window/door:"))
	(setvar "osmode" 0)
	(Setq A1 (Angle P1 P3))
	(Setq P3 (Polar P1 A1 A))
	(Setq A2 (Angle P1 P2))
	(Setq P4 (Polar P3 A2 (Distance P1 P2)))
	(Command "_break" P1 "_f" P1 P3 "_break" P2 "_f" P2 P4)
	(Command "_line" P1 P2 "" "_line" P3 P4 "")
	
	(Setq dicke (Distance P1 P2))
	(Setq P1A (Polar P1 A2 (- (/ dicke 2) 40)))
	(Setq P2A (Polar P1 A2 (+ (/ dicke 2) 40)))
	(Setq P3A (Polar P3 A2 (- (/ dicke 2) 40)))
	(Setq P4A (Polar P3 A2 (+ (/ dicke 2) 40)))
	(Command "_line" P1A P2A P4A P3A P1A "")

	(Princ)
)

