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

 (IF (/= G2SET NIL)
     (PROGN
        (SETQ FC (OPEN "/ACAD/HON/SET/G2.SET" "r"))
        (SETQ G2NUM (READ-LINE FC))
        (IF (OR (= G2NUM "") (= G2NUM NIL))
            (PROGN
               (CLOSE FC)
               (COMMAND G2)
            )
        )
       (IF (OR (= G2NUM NIL) (= G2NUM NIL))
         (PROGN
           (PROMPT "\nPLEASE SETTING LAYER IN GROUP 2:" )
           (SETQ FC (OPEN "/ACAD/HON/SET/G2.SET" "w"))
           (SETQ G2NUM (GETINT"\nHOW MANY LAYERS DO YOU WANT IN GROUP 2:"))
           (WRITE-LINE (ITOA G2NUM) FC)
           (SETQ ORDER 0)
           (REPEAT G2NUM
              (SETQ ORDER (+ ORDER 1))
              (SETQ ORDER1 (STRCAT (ITOA ORDER) "TH"))
              (PROMPT"\nKEYIN LAYER NAME:<")(PROMPT ORDER1)(PROMPT">")
              (SETQ G2LAY (GETSTRING T))
              (IF (= G2LAY "")
                  (WRITE-LINE "" FC)
                  (WRITE-LINE G2LAY FC)
              )
           )
           (CLOSE FC)
         )
       )
        (IF (/= G2NUM NIL)
           (PROGN
              (SETQ FC (OPEN "/ACAD/HON/SET/G2.SET" "r"))
              (SETQ G2NUM (READ-LINE FC))
              (SETQ G2NUM (ATOI G2NUM))
              (SETQ FY1 "")
              (SETQ FY "")
              (SETQ LAN (GETSTRING"\nCHANGE TO ?"))
              (PROMPT"\nALL GROUP 2 LAYERS WILL BE CHANGE TO:")
              (PROMPT LAN )
              (PROMPT"\n<")
              (REPEAT G2NUM
                 (SETQ G2LAY (READ-LINE FC))

                 (SETQ MAX (GETVAR "EXTMAX"))
                 (SETQ MIN (GETVAR "EXTMIN"))
                 (COMMAND "SELECT" "CROSSING" MIN MAX "")
                 (SETQ LA G2LAY)
                 (SETQ SA (SSGET "X" (LIST (CONS 8 LA))))
                 (IF (/= SA NIL)
                     (PROGN
                       (SETQ S1 SA)
                       (IF S1 (COMMAND "CHANGE" S1 "" "P" "COLOR" "BYLAYER" "LT" "BYLAYER" "LA" LAN ""))
                       (SETQ SA NIL)
                     )
                 )

                 (SETQ FY (STRCAT G2LAY "," FY))
                 (SETQ FY1 FY)
                 (PROMPT G2LAY)(PROMPT"  ")
                 (IF (= G2LAY "")
                     (PROGN
                       (COMMAND "G2")
                       (SETQ G2NUM 0)
                     )
                 )
              )
              (PROMPT">")
           (CLOSE FC)
           )
        )
     )
 )
