(defun C:clr()
;(IF (= (TYPE F1) 'FILE ) "YES"  (STOP))
;(IF (= (TYPE F2) 'FILE ) "YES" (STOP))
   (cond
      ((= En1 "LINE")
         (setq E1 (cdr (assoc 10 l1))
               E2 (cdr (assoc 11 l1))
               C1 (cdr (assoc 10 l2))
               R1 (cdr (assoc 40 l2))
               Pc (Lp E1 E2 C1)
               C t
         )
         (if (= En2 "CIRCLE") (setq E t)
            (setq E3 (polar C1 (cdr (assoc 50 l2)) R1)
                  E4 (polar C1 (cdr (assoc 51 l2)) R1)
                  E nil
            )
         )
      )
      (t
         (setq E1 (cdr (assoc 10 l2))
               E2 (cdr (assoc 11 l2))
               C1 (cdr (assoc 10 l1))
               R1 (cdr (assoc 40 l1))
               Pc (Lp E1 E2 C1)
               C nil
         )
         (if (= En1 "CIRCLE") (setq E t)
            (setq E3 (polar C1 (cdr (assoc 50 l1)) R1)
                  E4 (polar C1 (cdr (assoc 51 l1)) R1)
                  E nil
            )
         )
      )
   )
   (if (< pi (angle Pc C1)) (setq Ep E2 E2 E1 E1 Ep))
   (setq A0 (angle E1 E2)
         A1 (- (angle Pc P1) A0)
         A2 (- (angle Pc P2) A0)
         L (distance Pc C1)
   )
   (if (> R1 L)
      (progn
         (setq Pm (polar P1 (angle P1 P2) (* 0.5 (distance P1 P2)))
               Am (- (angle Pc Pm) A0)
               A (< 0 (sin Am))
               B (> R1 (distance C1 Pm))
               D (> 0 (cos Am))
               F nil
         )
         (if A (setq Y R) (setq Y (- 0 R) L (- 0 L)))
         (if B (setq R1 (- 0 R1)))
         (setq X (sqrt (* (+ R1 L) (- (+ R1 (* 2. R)) L))))
         (if D (setq X (- 0 X)))
      )
      (progn
         (setq B1 (< 0 (cos A1))
               B2 (< 0 (cos A2))
               B3 (or (and B1 (null B2)) (and (null B1) B2))
               F t
         )
         (if B3 (setq R1 (- 0 R1)))
         (setq X (sqrt (* (+ R1 L) (- (+ R1 (* 2. R)) L))))
         (if (and C (null B1)) (setq X (- 0 X)))
         (setq Y R A t B nil)
      )
   )
   (setq Cc (polar Pc (+ A0 (atan Y X)) (sqrt (+ (* X X) (* Y Y))))
         R1 (abs R1)
   )
   (command "erase" P1 P2 "")
   (if A (setq Pl (polar Cc (angle C1 Pc) R))
         (setq Pl (polar Cc (angle Pc C1) R))
   )
   (if B (setq Pa (polar Cc (angle C1 Cc) R))
         (setq Pa (polar Cc (angle Cc C1) R))
   )
   (if (or (and C A) (and (null C) (null A)))
       (command "line" E1 Pl "")
       (command "line" Pl E2 "")
   )
   (if F (setq B B3))
   (if E
      (if (or (and C B) (and (null C) (null B))
          )
         (command "arc" Pa "c" C1 "a" 180)
         (command "arc" Pa "c" C1 "a" -180)
      )
      (if (or (and C B) (and (null C) (null B)))
         (command "arc" Pa "c" C1 E4)
         (command "arc" E3 "c" C1 Pa)
      )
   )
   (if C
      (command "arc" Pl "c" Cc Pa)
      (command "arc" Pa "c" Cc Pl)
   )
)
