; START.LSP   [Article Figure 2]   (c)1990, Barry Bowen

; ***************************************************************
; Parametric System for Structural Steel Shapes
; Copyright (c) Barry R. Bowen 1989
;
; ----------------------- START ---------------------------------
; Start-up sub-routine
;
(defun START ()
  (CHKTOG)
  (V1 '("blipmode" "highlight" "filletrad" "snapbase"
        "snapmode"))
  (foreach N '("cmdecho" "blipmode" "highlight") (setvar N 0))
  (command "undo" "group")
)

; ----------------------- CHKTOG --------------------------------
; Check for plan, section, or elevation status
;
(defun CHKTOG () (if (not TOG) (TOGGLE) (TOGSTAT)))

; ----------------------- TOGGLE --------------------------------
; Toggle for Elevation, Plan, or Section drawing
; Variables:
; TOG = Toggle status E, P, or S
;
(defun TOGGLE ()
  (initget 1 "E P S")
  (setq TOG (getkword
           "\nDraw in <E>levation, <P>lan or <S>ection? "))
  (TOGSTAT)
)

; -------------------------- V1 ---------------- TOOLBOX, FEB '89
; Saves the original values of the specified
; system variables that will be changed. The specified
; system variables must not include any (read only)
; variables.
; Variables:
; SV    = List of system variables to save
; VLIST = List to store the specified system variables and
;         their original values.
;
; SAMPLE CALL: (V1 '("menuecho" "coords" "snapmode"))
;
(defun V1 (SV)
  (setq VLIST '())      ;Set VLIST to nil or empty
  (while SV
    (setq VLIST (append VLIST (list (list (car SV)
                               (getvar (car SV))))))
     (setq SV (cdr SV)) ;get next system variable in list
) )

; ------------------------ V1R ----------------- TOOLBOX, FEB '89
; V1R will restore the original system variables values
; that were changed during the execution of the Toolbox
; routine (V1).
; Variables:
; VLIST = List that stored the specified system
;         variables and their original values.
;
(defun V1R ()
  (while VLIST               ;Continue until VLIST is empty
     (setvar (caar VLIST) (cadar VLIST))
     (setq VLIST (cdr VLIST));Get next variable in list
) )

; ------------------------ HTOG ---------------------------------
; Toggle for Hatching ON/OFF
;
(defun HTOG ()
  (cond ((= HAT T) (setq HAT nil)
                   (princ "\nHatching OFF") (princ))
         (t (setq HAT T) (princ "\nHatching ON") (princ))
) )

; ----------------------- ANGTOG --------------------------------
; Double Angle toggle ON/OFF
;
(defun ANGTOG ()
  (cond ((= DOB T) (setq DOB nil)
                    (princ "\nSingle Angles") (princ))
         (t (setq DOB T) (princ "\nDouble Angles")
            (princ))
) )

; ---------------------- TOGSTAT --------------------------------
; Displays the current state of each Toggle
;
(defun TOGSTAT ()
  (if (not HAT) (prompt "\nHatching is OFF")
                (prompt "\nHatching is ON"))
  (if (not DOB) (prompt "\nSingle Angles")
                (prompt "\nDouble Angles"))
  (cond ((= TOG "P") (prompt"\nDrawing in Plan View\n"))
        ((= TOG "S") (prompt "\nDrawing in Section\n"))
        ((= TOG "E") (prompt "\nDrawing in Elevation\n")))
  (princ)
)

; -------------------- Miscellanous -----------------------------
;
(defun VC () (getvar "viewctr"))

(defun VS () (getvar "viewsize"))

(defun ZC (X)
    (if (> X (VS)) (command "zoom" "c" (VC) (* 1.5 X))))

(defun D90 () (* pi 0.5))

(defun D270 () (* pi 1.5))

(defun HLF (X) (/ X 2.0))

(defun LPT () (getvar "lastpoint"))

(defun SSET () (setq SL1 (ssadd (entlast) SL1)))
