;;;   ACAD.MNL
;;;   Copyright (C) 1992 by Autodesk, Inc.
;;;
;;;   Permission to use, copy, modify, and distribute this software
;;;   for any purpose and without fee is hereby granted, provided
;;;   that the above copyright notice appears in all copies and that
;;;   both that copyright notice and this permission notice appear in
;;;   all supporting documentation.
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;
;;;   AutoLISP routines used by the AutoCAD Release 12 Standard Menu.

(princ "\nAutoCAD Release 12 Men-Dienstprogramme ")


;;;=== Icon Menu Functions ===

;;;  View -> Layout -> Tiled Viewports...

(defun ai_tiledvp_chk ()
  (setq m:err *error* *error* *merrmsg*)
  (if (= (getvar "TILEMODE") 0)
    (progn
      (princ "\n** Befehl nur aufrufbar, wenn TILEMODE auf 1 (Ein) gesetzt ist **")
      (princ)
    )
    (progn
      (menucmd "I=VPORTI")
      (menucmd "I=*")
    )
  )
  (setq *error* m:err m:err nil)
  (princ)
)

(defun ai_tiledvp (num ori / ai_tiles_g ai_tiles_cmde)
  (setq m:err *error* *error* *merrmsg*
        ai_tiles_cmde (getvar "CMDECHO")
        ai_tiles_g (getvar "GRIDMODE")
  )
  (setvar "CMDECHO" 0)
  (setvar "GRIDMODE" 0)
  (cond ((= num 1)
         (command "_.VPORTS" "_SI")
         (setvar "GRIDMODE" ai_tiles_g)
        )
        ((< num 4)
         (command "_.VPORTS" "_SI")
         (command "_.VPORTS" num ori)
         (setvar "GRIDMODE" ai_tiles_g)
        )
        ((= ori nil)
         (command "_.VPORTS" "_SI")
         (command "_.VPORTS" num)
         (setvar "GRIDMODE" ai_tiles_g)
        )
        ((= ori "L")
         (command "_.UNDO" "_M")
         (command "_.VPORTS" "_SI")
         (command "_.VPORTS" "2" "")
         (setvar "CVPORT" (car (cadr (vports))))
         (command "_.VPORTS" "2" "")
         (command "_.VPORTS" "_J" "" (car (cadr (vports))))
         (setvar "CVPORT" (car (cadr (vports))))
         (command "_.VPORTS" "3" "_H")
         (setvar "GRIDMODE" ai_tiles_g)
         (setvar "CVPORT" (car (cadddr (vports))))
         (setvar "GRIDMODE" ai_tiles_g)
         (setvar "CVPORT" (car (cadddr (vports))))
         (setvar "GRIDMODE" ai_tiles_g)
         (setvar "CVPORT" (car (cadddr (vports))))
         (setvar "GRIDMODE" ai_tiles_g)
         (command "_.UNDO" "_E")
        )
        (T
         (command "_.UNDO" "_M")
         (command "_.VPORTS" "_SI")
         (command "_.VPORTS" "2" "")
         (command "_.VPORTS" "2" "")
         (setvar "CVPORT" (car (caddr (vports))))
         (command "_.VPORTS" "_J" "" (car (caddr (vports))))
         (setvar "CVPORT" (car (cadr (vports))))
         (command "_.VPORTS" "3" "_H")
         (setvar "GRIDMODE" ai_tiles_g)
         (setvar "CVPORT" (car (cadddr (vports))))
         (setvar "GRIDMODE" ai_tiles_g)
         (setvar "CVPORT" (car (cadddr (vports))))
         (setvar "GRIDMODE" ai_tiles_g)
         (setvar "CVPORT" (car (cadddr (vports))))
         (setvar "GRIDMODE" ai_tiles_g)
         (command "_.UNDO" "_E")
        )
  )
  (setq *error* m:err m:err nil)
  (setvar "CMDECHO" ai_tiles_cmde)
  (princ)
)

;;;=== Tablet Swap Functions ===

(defun ai_tab1 ()
  (if (null T_MENU)
    (setq T_MENU 0)
  )
  (if (= (logand 1 T_MENU) 1)
    (progn (setq T_MENU (- T_MENU 1))
      (if (< (getvar "EXPERT") 4)
        (princ "\nAlternativer Tablettbereich 1 wurde desaktiviert.")
      )
      (menucmd "T1=TABLET1")
      (if (< (getvar "EXPERT") 1)
        (princ "\nW„hlen Sie eine Option des AutoCAD AME oder der AutoShade Tablettmens.\n")
      )
    )
    (progn 
      (setq T_MENU (+ T_MENU 1))
      (if (< (getvar "EXPERT") 4)
        (princ "\nAlternativer Tablettbereich 1 geladen.  ")
      )
      (menucmd "T1=TABLET1ALT")
      (if (< (getvar "EXPERT") 1)
        (princ "\nDieser Bereich steht Ihnen fr Ihre eigenen Anwendungen und Men-Optionen zur Verfgung.\n")
      )
    )
  )
  (menucmd (strcat "s=HEADER" (itoa T_MENU)))
  (princ)
)

(defun ai_tab2 ()
  (if (null T_MENU) (setq T_MENU 0))
  (if (= (logand 2 T_MENU) 2)
    (progn
      (setq T_MENU (- T_MENU 2))
      (if (< (getvar "EXPERT") 4)
        (princ "\nAlternativer Tablettbereich 2 wurde desaktiviert.  ")
      )
      (menucmd "T2=TABLET2")
      (if old_wv (setvar "WORLDVIEW" old_wv))
      (if (< (getvar "EXPERT") 1)
        (princ "\nBefehle transparent aufrufbar: APUNKT und DANSICHT im Weltansichtsmodus.\n")
      )
    )
    (progn
      (setq T_MENU (+ T_MENU 2))
      (setq old_wv (getvar "WORLDVIEW"))
      (setvar "WORLDVIEW" 0)
      (if (< (getvar "EXPERT") 4)
        (princ "\nAlternativer Tablettbereich 2 geladen.  ")
      )
      (menucmd "T2=TABLET2ALT")
      (if (< (getvar "EXPERT") 1)
        (princ "\nZoom und andere Befehle geben CTRL-C Kombinationen aus: APUNKT und DANSICHT im aktuellen BKS-Modus.\n")
      )
    )
  )
  (menucmd (strcat "s=HEADER" (itoa T_MENU)))
  (princ)
)

(defun ai_tab3 ()
  (if (null T_MENU) 
    (setq T_MENU 0)
  )
  (if (= (logand 4 T_MENU) 4)
    (progn
      (setq T_MENU (- T_MENU 4))
      (if (< (getvar "EXPERT") 4)
        (princ "\nAlternativer Tablettbereich 3 wurde desaktiviert.  ")
      )
      (menucmd "T3=TABLET3")
      (if (< (getvar "EXPERT") 1)
        (princ "\nW„hlen Sie metrische Einheiten aus dem Numerik-Men aus.\n")
      )
    )
    (progn
      (setq T_MENU (+ T_MENU 4))
      (if (< (getvar "EXPERT") 4)
        (princ "\nAlternativer Tablettbereich 3 geladen.  ")
      )
      (menucmd "T3=TABLET3ALT")
      (if (< (getvar "EXPERT") 1)
        (princ "\nW„hlen Sie amerikanische Einheiten aus dem Numerik-Men aus.\n")
      )
    )
  )
  (menucmd (strcat "s=HEADER" (itoa T_MENU)))
  (princ)
)

(defun ai_tab4 ()
  (if (null T_MENU) 
    (setq T_MENU 0)
  )
  (if (= (logand 8 T_MENU) 8)
    (progn
      (setq T_MENU (- T_MENU 8))
      (if (< (getvar "EXPERT") 4)
        (princ "\nAlternativer Tablettbereich 4 wurde desaktiviert.  ")
      )
      (menucmd "T4=TABLET4")
      (if (< (getvar "EXPERT") 1)
        (princ "\nObjektfangmodi geben Unterdrckungsanweisungen aus: Befehle werden NICHT wiederholt.\n")
      )
    )
    (progn
      (setq T_MENU (+ T_MENU 8))
      (if (< (getvar "EXPERT") 4)
        (princ "\nAlternativer Tablettbereich 4 geladen.  ")
      )
      (menucmd "T4=TABLET4ALT")
      (if (< (getvar "EXPERT") 1)
        (princ "\nObjektfangmodi geben geben Anweisungen zum fortlaufenden Betrieb aus: Befehle werden wiederholt.\n")
      )
    )
  )
  (menucmd (strcat "s=HEADER" (itoa T_MENU)))
  (princ)
)

;;;=== General Utility Functions ===

(defun *merr* (msg)
  (setq *error* m:err m:err nil)
  (princ)
)

(defun *merrmsg* (msg)
  (princ msg)
  (setq *error* m:err m:err nil)
  (princ)
)

(defun c:rectang ( / cmde pt1 pt2)
  (setq m:err *error* *error* *merr*
        cmde (getvar "CMDECHO")
  )
  (setvar "CMDECHO" 0)
  (setq pt1 (getpoint "\nErster Eckpunkt: ")
        pt2 (getcorner pt1 "\nZweiter Eckpunkt: ")
  )
  (command "_.PLINE" pt1 (list (car pt1) (cadr pt2))
                   pt2 (list (car pt2) (cadr pt1))
           "_C"
  )
  (setvar "CMDECHO" cmde)
  (setq *error* m:err m:err nil)
  (princ)
)

(defun c:rechteck() (c:rectang))

(defun c:ai_peditm (/ m:p0 m:p1)
  (setq m:err *error* *error* *merr*)
  (defun m:p0 (/ m:s1 m:e1 m:e2 m:e3)
    (menucmd"S=X")
    (menucmd"S=PSEL")
    (while (not m:s1)
      (if (setq m:s1 (ssget))
        (progn
          (setq m:e1 (ssname m:s1 0)
                m:e2 (entget m:e1)
                m:e3 (cdr (assoc 0 m:e2))
          )
          (if (= m:e3 "POLYLINE")
            (m:p1)
            (if (member m:e3 '("LINE" "ARC"))
              (progn
                (command "_.PEDIT" m:e1 pause)
                (menucmd "S=X")
                (menucmd "S=P0")
              )
              (progn
                (terpri)
                (princ "Das gew„hlte Objekt ist keine Polylinie.")
                (terpri)
                (setq m:s1 nil)
              )
            )
          )
        )
      )
    )
  )
  (defun m:p1 (/ m:a)
    (menucmd"S=X")
    (if (= (setq m:a (cdr (assoc 70 m:e2))) nil)
      (menucmd"S=P0")
      (progn
        (setq m:a (/ m:a 2))
        (if (>= m:a 8)
          (menucmd"S=P16")
          (if (< m:a 4)
            (menucmd"S=P0")
            (menucmd"S=P8")
          )
        )
      )
    )
    (command "_.PEDIT" m:e1)
  )
  (m:p0)
  (setq *error* m:err m:err nil)
  (princ)
)

;;;=== Menu Functions ===

(defun ai_rootmenus ()
  (setq T_MENU 0)
  (menucmd "S=X")
  (menucmd "S=S")
  (menucmd "T2=TABLET2")
  (menucmd "T3=TABLET3")
  (menucmd "T4=TABLET4")
  (princ)
)

(if (not (load "acadr12.lsp" nil))
  (progn
    (princ "Ladefehler.")
    (princ "\nacadr12.lsp nicht gefunden.  AutoLoader wurde desaktiviert.  ")
    (princ "Weitere Dienstprogramme ")
  )
  (progn
    (ai_loadaverendr)
    (ai_aloadame)
    (ai_asegrey "~")
  )
)

(setvar "MENUCTL" 1)

(princ "geladen.")
(princ)
