DEFUN C:GRERASE5
;SET LAYER
(COMMAND "SETVAR" "CMDECHO" 0)
(SETQ NY (GETVAR "CLAYER"))
;(IF (= (TYPE F1) 'FILE ) "YES"  (STOP))
;(IF (= (TYPE F2) 'FILE ) "YES" (STOP))
(setq G5SET (findfile "/ACAD/HON/SET/G5.SET"))
(IF (= G5SET NIL)
    (PROGN
       (PROMPT "\nPLEASE SETTING LAYER IN GROUP 5:" )
       (SETQ FC (OPEN "/ACAD/HON/SET/G5.SET" "w"))
       (SETQ G5NUM (GETINT"\nHOW MANY LAYERS DO YOU WANT IN GROUP 5:"))
       (WRITE-LINE (ITOA G5NUM) FC)
       (SETQ ORDER 0)
       (REPEAT G5NUM
          (SETQ ORDER (+ ORDER 1))
          (SETQ ORDER1 (STRCAT (ITOA ORDER) "TH"))
          (PROMPT"\nKEYIN LAYER NAME:<")(PROMPT ORDER1)(PROMPT">")
          (SETQ G5LAY (GETSTRING T))
          (IF (= G5LAY "")
              (WRITE-LINE "" FC)
              (WRITE-LINE G5LAY FC)
          )
       )
       (CLOSE FC)
    )
)

 (IF (/= G5SET NIL)
     (PROGN
        (SETQ FC (OPEN "/ACAD/HON/SET/G5.SET" "r"))
        (SETQ G5NUM (READ-LINE FC))
;       (SETQ G5LAY (READ-LINE FC))
        (IF (OR (= G5NUM "") (= G5NUM NIL))
            (PROGN
               (CLOSE FC)
               (COMMAND G5)
            )
        )
       (IF (OR (= G5NUM NIL) (= G5NUM NIL))
         (PROGN
           (PROMPT "\nPLEASE SETTING LAYER IN GROUP 5:" )
           (SETQ FC (OPEN "/ACAD/HON/SET/G5.SET" "w"))
           (SETQ G5NUM (GETINT"\nHOW MANY LAYERS DO YOU WANT IN GROUP 5:"))
           (WRITE-LINE (ITOA G5NUM) FC)
           (SETQ ORDER 0)
           (REPEAT G5NUM
              (SETQ ORDER (+ ORDER 1))
              (SETQ ORDER1 (STRCAT (ITOA ORDER) "TH"))
              (PROMPT"\nKEYIN LAYER NAME:<")(PROMPT ORDER1)(PROMPT">")
              (SETQ G5LAY (GETSTRING T))
              (IF (= G5LAY "")
                  (WRITE-LINE "" FC)
                  (WRITE-LINE G5LAY FC)
              )
           )
           (CLOSE FC)
         )
       )
        (IF (/= G5NUM NIL)
           (PROGN
              (SETQ FC (OPEN "/ACAD/HON/SET/G5.SET" "r"))
              (SETQ G5NUM (READ-LINE FC))
              (SETQ G5NUM (ATOI G5NUM))
              (SETQ FY1 "")
              (SETQ FY "")
              (PROMPT"\nGROUP 5 LAYERS HAVE:")
              (PROMPT "<" )
              (REPEAT G5NUM
                 (SETQ G5LAY (READ-LINE FC))

                 (SETQ MAX (GETVAR "EXTMAX"))
                 (SETQ MIN (GETVAR "EXTMIN"))
                 (COMMAND "SELECT" "CROSSING" MIN MAX "")
                 (SETQ LA G5LAY)
                 (SETQ SA (SSGET "X" (LIST (CONS 8 LA))))
                 (IF (/= SA NIL)
                     (PROGN
                       (COMMAND "ERASE" SA "")
                       (SETQ SA NIL)
                     )
                 )

                 (SETQ FY (STRCAT G5LAY "," FY))
                 (SETQ FY1 FY)
                 (PROMPT G5LAY)(PROMPT"  ")
                 (IF (= G5LAY "")
                     (PROGN
                       (COMMAND "G5")
                       (SETQ G5NUM 0)
                     )
                 )
              )
              (PROMPT">")
           (CLOSE FC)
           )
        )
     )
 )
