(defun edit_cleaning_line_profil (p t1_ins_z t2_ins_z / nabor line t1 t2 n1 n2)
  (setq nabor (ssget "_X" (list (cons 0 "LINE") )))
  (if (/= nabor nil)
    (progn
      (setq n1 (sslength nabor))
      (setq n2 0)
      (repeat n1
	(setq line (entget(ssname nabor n2)))
	(setq t1 (cdr (assoc 10 line)))
	(setq t2 (cdr (assoc 11 line)))
	(cond
	  ((and (= (nth 0 p) (nth 0 t1))(= (nth 0 p) (nth 0 t2)) (>(nth 1 t1)(nth 1 t2_ins_z)) (<(nth 1 t2)(nth 1 t1_ins_z)))
	   (entdel (cdr (assoc -1 line)))
	   (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 t1) (cons 11 (list (nth 0 p)(nth 1 t2_ins_z)))))
	   (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (list (nth 0 p)(nth 1 t1_ins_z))) (cons 11 t2)))
	   )
	  ((and (= (nth 0 p) (nth 0 t1))(= (nth 0 p) (nth 0 t2)) (>(nth 1 t1)(nth 1 t2_ins_z)) (<(nth 1 t2)(nth 1 t2_ins_z)))
	   (entdel (cdr (assoc -1 line)))
	   (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 t1) (cons 11 (list (nth 0 p)(nth 1 t2_ins_z)))))
	   )
	  ((and (= (nth 0 p) (nth 0 t1))(= (nth 0 p) (nth 0 t2)) (>(nth 1 t1)(nth 1 t1_ins_z)) (<(nth 1 t2)(nth 1 t1_ins_z)))
	   (entdel (cdr (assoc -1 line)))
	   (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (list (nth 0 p)(nth 1 t1_ins_z))) (cons 11 t2)))
	   )
	  ((and (= (nth 0 p) (nth 0 t1))(= (nth 0 p) (nth 0 t2)) (equal(nth 1 t1)(nth 1 t2_ins_z)0.0001) (equal(nth 1 t2)(nth 1 t1_ins_z)0.0001))
	   (entdel (cdr (assoc -1 line)))
	   )
	  )
	(setq n2 (1+ n2))
	)
      )
    )
  )
