(defun CHO ()    ;change " " to  "" ,string is "str"
               (setq si 1)
               (while (= 1 (setq sl (strlen
                             (setq st (substr str si 1)))))
                  (if (= st " ")
                      (progn
                        (setq str (strcat (substr str 1 (1- si)) ""
                                        (substr str (+ si 1))))
                      )
                      (setq si (1+ si))
                  )
               )
)


 (defun j()   ;trim 1~20 + 21~40 , 41~60 + 61~80 , 81 , erase " "
       (setq pointx1 (substr s 1 20))
       (setq pointy1 (substr s 21 20))
       (setq str (strcat pointx1 "," pointy1))
       (cho)
       (setq point1 str)

       (setq pointx2 (substr s 41 20))
       (setq pointy2 (substr s 61 20))
       (setq str (strcat pointx2 "," pointy2))
       (cho)
       (setq point2 str)

       (setq color1 (substr s 81 1))
)


(defun i()  ;draw lines ,break the cross
       (command "color" color1)
       (command "line" point1 point2 "")
   (setq M1 (cdr (assoc 10 (entget (ssname (ssget "L") 0)))))
   (setq M2 (cdr (assoc 11 (entget (ssname (ssget "L") 0)))))

   (setq in1 (inters m1 m2 aa1 2p)
         in2 (inters m1 m2 2p aa2)
         in3 (inters m1 m2 aa2 1p)
         in4 (inters m1 m2 1p aa1)
   )
   (if in1 (command "break" in1 "@"))
   (if in2 (command "break" in2 "@"))
   (if in3 (command "break" in3 "@"))
   (if in4 (command "break" in4 "@"))
)

(defun c:link()     ;main program
       (setvar "cmdecho" 0)
       (command "limits" "-2000,-2000" "2000,2000")
       (command "zoom" "all")
       (command "color" 7)
(setq fname (getstring "\nPlease Input The File name :"))
 (if (setq fn (findfile fname))
   (progn (setq f (open fn "r"))
    (setq s (read-line f))
       (setq pointx2 (substr s 1 20))
       (setq pointy2 (substr s 21 20))
       (setq str (strcat pointx2 "," pointy2))
       (cho)
       (setq a1 str)
    (setq s (read-line f))
       (setq pointx2 (substr s 1 20))
       (setq pointy2 (substr s 21 20))
       (setq str (strcat pointx2 "," pointy2))
       (cho)
       (setq a2 str)
    (COMMAND "LINE" a1 a2 "")
    (setq aa1 (cdr (assoc 10 (entget (ssname (ssget "L") 0)))))
    (setq aa2 (cdr (assoc 11 (entget (ssname (ssget "L") 0)))))
    (if (< (CAR aa1) (CAR aa2)) (setq nub 123) (setq nub nil))
    (SETQ  X1 (CAR aa1) Y1 (CADR aa1) X2 (CAR aa2) Y2 (CADR aa2))
    (SETQ 1P (LIST x1 y2))
    (SETQ 2P (LIST x2 y1))
    (setq mx (/ (+ x1 x2) 2.0) my (/ (+ y1 y2) 2.0) )
    (COMMAND "u")
       (command "color" 7)
       (command "limits" "-2000,-2000" "2000,2000")
       (command "zoom" "all")
    (COMMAND "PLINE" aa1 "W" 0.2 0.2 1P aa2 2P "C")
    (setq str (read-line f))
     (cho)
    (setq a4 (atoi str))
    (setq n 0)
    (repeat a4
       (setq s (read-line f))
       (setq n (+ n 1))
       (j)
       (i)
    )

  (setq ss1 (ssget "W" aa1 aa2) ss2 (ssget "x"))
  (if (not ss1) (command "erase" ss2 "")
   (progn
     (setq ss3 (ssadd) n 0)
     (repeat (sslength ss2)
      (setq ent (ssname ss2 n))
      (if (not (ssmemb ent ss1))
                (ssadd ent ss3)
      )
      (setq n (+ 1 n))
     )
    (command "erase" ss3 "" "redraw")
   )
  )
    (command "color" 7)
    (COMMAND "PLINE" aa1 "W" 0.2 0.2 1P aa2 2P "C")
    (command "setvar" "mirrtext" 0)
    (if nub (command "mirror" (ssget"x") "" (list 0 my) (list 100 my) "Y"))
    (command "color" 7)
    (while (setq rec (read-line f))
       (setq s rec)
       (setq pointx2 (substr s 1 20))
       (setq pointy2 (substr s 21 20))
       (setq str (strcat pointx2 "," pointy2))
       (cho)
       (setq point3 str)
       (setq txt (substr rec 41))
       (command "text" "m" point3 2.5 0 txt)
    )
       (command "zoom" "e")
   )
    (progn (princ "File ")(princ (strcase fname))(princ " not exit!"))
  )
   (close f)
   (setvar "cmdecho" 1)
  (print "It is end! thank you for use!")
  (princ)
)
                                        