(DEFUN C:KO1()
;SET LAYER
(COMMAND "SETVAR" "CMDECHO" 0)
(SETQ NY (GETVAR "CLAYER"))
;(IF (= (TYPE F1) 'FILE ) "YES"  (STOP))
;(IF (= (TYPE F2) 'FILE ) "YES" (STOP))
(setq KOSET (findfile "c:/acad/ACAD/SUPPORT/KO.SET"))
(IF (= KOSET NIL)
    (PROGN
       (PROMPT "\nPLEASE SETTING LAYER OF KO:" )
       (SETQ FC (OPEN "c:/acad/ACAD/SUPPORT/KO.SET" "w"))
       (setq KOCNT (GETSTRING T"\nSETTING KO LAYER OF CONTNIUE LINE/<DRAW>:"))
       (IF (= KOCNT "")
              (WRITE-LINE "DRAW" FC)
              (WRITE-LINE KOCNT FC)
       )
       (setq KOCEN (GETSTRING T"\nSETTING KO LAYER OF CENTER LINE/<CENTER>:"))
       (IF (= KOCEN "")
              (WRITE-LINE "CENTER" FC)
              (WRITE-LINE KOCEN FC)
       )
       (setq KOHID (GETSTRING T"\nSETTING KO LAYER OF HIDDEN LINE/<HIDDEN>:"))
       (IF (= KOHID "")
              (WRITE-LINE "HIDDEN" FC)
              (WRITE-LINE KOHID FC)
       )
       (setq KODIM (GETSTRING T"\nSETTING KO LAYER OF DIMESION /<TEXT>:"))
       (IF (= KODIM "")
              (WRITE-LINE "TEXT" FC)
              (WRITE-LINE KODIM FC)
       )
       (setq KOTXT (GETSTRING T"\nSETTING KO LAYER OF TEXT /<TEXT>:"))
       (IF (= KOTXT "")
              (WRITE-LINE "TEXT" FC)
              (WRITE-LINE KOTXT FC)
       )
       (CLOSE FC)
    )
)

(IF (/= KOSET NIL)
    (PROGN
       (SETQ FC (OPEN "c:/acad/ACAD/SUPPORT/KO.SET" "r"))
       (SETQ KOCNT (READ-LINE FC))
       (SETQ KOCEN (READ-LINE FC))
       (SETQ KOHID (READ-LINE FC))
       (SETQ KODIM (READ-LINE FC))
       (SETQ KOTXT (READ-LINE FC))
       (IF (OR (= KOCNT "") (= KOCEN "") (= KOHID "") (= KODIM "") (= KOTXT "")
               (= KOCNT NIL) (= KOCEN NIL) (= KOHID NIL) (= KODIM NIL) (= KOTXT NIL))
           (CLOSE FC)
       )
       (IF (OR (= KOCNT "") (= KOCEN "") (= KOHID "") (= KODIM "") (= KOTXT "")
               (= KOCNT NIL) (= KOCEN NIL) (= KOHID NIL) (= KODIM NIL) (= KOTXT NIL))
           (PROGN
              (PROMPT "\nPLEASE SETTING LAYER OF KO:" )
              (SETQ FC (OPEN "c:/acad/ACAD/SUPPORT/KO.SET" "w"))
              (setq KOCNT (GETSTRING T"\nSETTING KO LAYER OF CONTNIUE LINE/<DRAW>:"))
              (IF (= KOCNT "")
                  (WRITE-LINE "DRAW" FC)
                  (WRITE-LINE KOCNT FC)
              )
              (setq KOCEN (GETSTRING T"\nSETTING KO LAYER OF CENTER LINE/<CENTER>:"))
              (IF (= KOCEN "")
                  (WRITE-LINE "CENTER" FC)
                  (WRITE-LINE KOCEN FC)
              )
              (setq KOHID (GETSTRING T"\nSETTING KO LAYER OF HIDDEN LINE/<HIDDEN>:"))
              (IF (= KOHID "")
                  (WRITE-LINE "HIDDEN" FC)
                  (WRITE-LINE KOHID FC)
              )
              (setq KODIM (GETSTRING T"\nSETTING KO LAYER OF DIMENSION /<TEXT>:"))
              (IF (= KODIM "")
                  (WRITE-LINE "TEXT" FC)
                  (WRITE-LINE KODIM FC)
              )
              (setq KOTXT (GETSTRING T"\nSETTING KO LAYER OF TEXT /<TEXT>:"))
              (IF (= KOTXT "")
                  (WRITE-LINE "TEXT" FC)
                  (WRITE-LINE KOTXT FC)
              )
           (CLOSE FC)
           )
       )
       (SETQ FC (OPEN "c:/acad/ACAD/SUPPORT/KO.SET" "r"))
       (SETQ KOCNT (READ-LINE FC))
       (SETQ KOCEN (READ-LINE FC))
       (SETQ KOHID (READ-LINE FC))
       (SETQ KODIM (READ-LINE FC))
       (SETQ KOTXT (READ-LINE FC))
       (CLOSE FC)
       (PROMPT "\nKO CONTINUE OF LAYER IS:" )(PROMPT KOCNT)(TERPRI)
       (PROMPT "\nKO CENTER OF LAYER IS:" ) (PROMPT KOCEN)(TERPRI)
       (PROMPT "\nKO HIDDEN OF LAYER IS:" ) (PROMPT KOHID)(TERPRI)
       (PROMPT "\nKO DIMENSION OF LAYER IS:" ) (PROMPT KODIM)(TERPRI)
       (PROMPT "\nKO TEXT  OF LAYER IS:" ) (PROMPT KOTXT)(TERPRI)
    )
)

(SETQ ANS (strcase (GETSTRING "\nDO YOU WANT TO CHANGE LAST SETTING <Y/N> N:")))
(IF (= ANS "Y")
    (PROGN
       (PROMPT "\nPLEASE SETTING LAYER:" )
       (SETQ FC (OPEN "c:/acad/ACAD/SUPPORT/KO.SET" "w"))
       (PROMPT "\nKO CONTINUE OF LAYER <")(PROMPT KOCNT)(PROMPT">:")
       (setq KOCNT (GETSTRING T))
       (IF (= KOCNT "")
              (WRITE-LINE "DRAW" FC)
              (WRITE-LINE KOCNT FC)
       )
       (PROMPT "\nKO CENTER OF LAYER <")(PROMPT KOCEN)(PROMPT">:")
       (setq KOCEN (GETSTRING T))
       (IF (= KOCEN "")
              (WRITE-LINE "CENTER" FC)
              (WRITE-LINE KOCEN FC)
       )
       (PROMPT "\nKO HIDDEN OF LAYER <")(PROMPT KOHID)(PROMPT">:")
       (setq KOHID (GETSTRING T))
       (IF (= KOHID "")
              (WRITE-LINE "HIDDEN" FC)
              (WRITE-LINE KOHID FC)
       )
       (PROMPT "\nKO THE WORDS <")(PROMPT KODIM)(PROMPT">:")
       (setq KODIM (GETSTRING T))
       (IF (= KODIM "")
              (WRITE-LINE "TEXT" FC)
              (WRITE-LINE KODIM FC)
       )
       (PROMPT "\nKO TEXT OF LAYER <")(PROMPT KOTXT) (PROMPT">:")
       (setq KOTXT (GETSTRING T))
       (IF (= KOTXT "")
              (WRITE-LINE "TEXT" FC)
              (WRITE-LINE KOTXT FC)
       )
       (CLOSE FC)
       (SETQ FC (OPEN "c:/acad/ACAD/SUPPORT/KO.SET" "r"))
       (SETQ KOCNT (READ-LINE FC))
       (SETQ KOCEN (READ-LINE FC))
       (SETQ KOHID (READ-LINE FC))
       (SETQ KODIM (READ-LINE FC))
       (SETQ KOTXT (READ-LINE FC))
       (CLOSE FC)
       (PROMPT "\nKO CONTINUE OF LAYER NOW IS:" )(PROMPT KOCNT)(TERPRI)
       (PROMPT "\nKO CENTER   OF LAYER NOW IS:" ) (PROMPT KOCEN)(TERPRI)
       (PROMPT "\nKO HIDDEN   OF LAYER NOW IS:" ) (PROMPT KOHID)(TERPRI)
       (PROMPT "\nKO DIMENSION OF LAYER IS:" ) (PROMPT KODIM)(TERPRI)
       (PROMPT "\nKO TEXT   OF WORD IS:" ) (PROMPT KOTXT)(TERPRI)
  )
)


;THE POINT IS FIST COUNTER Y THEN X
(MENUCMD "S=KO")
;(COMMAND "UJ" "")
(GRAPHSCR) (TERPRI)                                     ;GRAPHICS MODE

(setq D (getreal "Enter KO diameter:"))
(PROMPT"\nEnter plate thickness:")
(SETQ P1 (GETPOINT "\nFIRST POINT:"))
(SETQ P2 (GETPOINT P1 "\nSECOND POINT:"))
(SETQ ag1 (ANGLE P1 P2))
(SETQ AG2 (* PI 0.5))
(SETQ LSE (DISTANCE P1 P2))
(SETQ DR1 (POLAR (POLAR P1 AG1 1) (+ AG1 AG2) (/ D 2.0)))
(SETQ DR2 (POLAR (POLAR P1 AG1 1) (- AG1 AG2) (/ D 2.0)))
(SETQ DR3 (POLAR (POLAR P1 AG1 (- LSE 1)) (+ AG1 AG2) (/ D 2.0)))
(SETQ DR4 (POLAR (POLAR P1 AG1 (- LSE 1)) (- AG1 AG2) (/ D 2.0)))

(SETQ DR5 (POLAR DR1 (+ AG1 (DTR 135)) 1.44))
(SETQ DR6 (POLAR DR2 (- AG1 (DTR 135)) 1.44))
(SETQ DR7 (POLAR DR3 (+ AG1 (DTR 45)) 1.44))
(SETQ DR8 (POLAR DR4 (- AG1 (DTR 45)) 1.44))

;ABOVE FIRST BOX
;(IF  (= ANS1 "N")
;     (COMMAND "LAYER" "SET" KOHID "")
;     (COMMAND "LAYER" "SET" KOCNT "")
;)
(COMMAND "LINE" DR1 DR2 "")
(COMMAND "LINE" DR1 DR3 "")
(COMMAND "LINE" DR2 DR4 "")
(COMMAND "LINE" DR3 DR4 "")
(COMMAND "LINE" DR1 DR5 "")
(COMMAND "LINE" DR2 DR6 "")
(COMMAND "LINE" DR3 DR7 "")
(COMMAND "LINE" DR4 DR8 "")
;BOX ABOVE

(COMMAND "LAYER" "SET" KOCEN "")
(COMMAND "LINE" (POLAR P1 AG1 -1) (POLAR P1 AG1 (+ 1 LSE)) "")

;HERE IS TEXT
(SETQ TT1 (POLAR (POLAR  P1 AG1 (- (/ LSE 3) 1.5)) (+ AG1 AG2) 2.8))
(SETQ TT3 (POLAR (POLAR P1 AG1 (* LSE 0.66)) (+ AG1 AG2) (/ D 2.0)))
(SETQ TT4 (POLAR (POLAR P1 AG1 (* LSE 0.66)) (- AG1 AG2) (/ D 2.0)))
 (IF (< D 10)
     (SETQ TT5 (POLAR (POLAR P1 AG1 (* LSE 0.6))  (+ AG1 AG2) 2.6))
     (SETQ TT5 (POLAR (POLAR P1 AG1 (* LSE 0.6))  (+ AG1 AG2) 4))
 )
(SETQ LP (GETVAR "LUPREC"))   ;LP DIGITAL
(SETQ D1 (RTOS D 2 LP))
(SETQ D11 (FIX (ATOF D1)))
(SETQ RET (- D D11))
(IF (OR (= RET 0) (= RET 0.0) (= RET 0.00))
    (PROGN
       (SETQ SR (- (STRLEN D1) LP 1))
       (SETQ D1 (SUBSTR D1 1 SR))
    )
)
(COMMAND "LAYER" "SET" KOTXT "")
(COMMAND "TEXT" TT1 3.0 (RTD (- AG1 AG2)) "KO")


(SETQ DD (STRCAT "%%C" D1))
(COMMAND "LAYER" "SET" KODIM "")
(IF (= AG1 (DTR 270))
    (PROGN
      (COMMAND "DIM" "ALIGNED" TT3 TT4 TT3 "  " "EXIT")
      (COMMAND "TEXT" TT5 3 (RTD (- AG1 AG2)) DD)
    )
)
(IF (/= AG1 (DTR 270))
    (COMMAND "DIM" "ALIGNED" TT3 TT4 TT4 DD "EXIT")
)
;
(COMMAND "LAYER" "SET" NY "")
)
