(defun C:draw_profile_be_h_and_distance (/ t1 t2 t3 p p1 p2 p3 n pl_prof t0 ht styl z tp dcl_id a b g tt ttt 2dpline ang d1 d2 dxf h1 h2 hs htz list_points max_z mg min_z mleader_obj model_spece mv n_00 pline pro pro! pt_array q_chek_v_pr q_draw_line q_draw_pr q_draw_rasst q_draw_ugli q_draw_uklon q_ins_m q_ins_podval q_ins_z q_sel_str_z q_sel_uklon q_sel_v_pr q_x q_xyz q_y q_z s sp_lin t0! t1! t1- t11 t1_draw_rasst t1_draw_uklon t1_ins_z t2- t22 t2_draw_rasst t2_draw_uklon t2_ins_z t_do_linii usl_z x z1 z2)
  ; чертит профиль по расстояниям и отметкам
     (setq mv 100.0)
     (setq mg 500.0)
     (setq usl_z 100.0)
     (setq dcl_id (geo-tools-load-dialog "d_create_2d_profil"))
     (new_dialog "d_create_2d_profil" dcl_id)
     (mode_tile "sel_v_pr" 1)
     (mode_tile "sel_str_z" 1)
     (mode_tile "sel_uklon" 1)
     (mode_tile "xp" 1)
     (mode_tile "yp" 1)
     (mode_tile "zp" 1)
     (if (/= t1! nil)
       (progn
	 (setq q_x (rtos(nth 0 t1!)2 3))
	 (setq q_y (rtos(nth 1 t1!)2 3))
	 (setq q_z (rtos(nth 2 t1!)2 3))
	 )
       (progn
	 (setq q_x "0.000")
	 (setq q_y "0.000")
	 (setq q_z "0.000")
	 )
       )
     (set_tile "xp" q_x)
     (set_tile "yp" q_y)
     (set_tile "zp" q_z)
     (setq q_draw_pr 0)
     (setq q_xyz 1)
     (setq q_sel_v_pr 0)
     (setq q_ins_z 0)
     (setq q_ins_m 0)
     (setq q_draw_uklon 0)
     (setq q_draw_line 0)
     (setq q_draw_ugli 0)
     (setq q_draw_rasst 0)
     (setq q_sel_str_z 0)
     (setq q_chek_v_pr 0)
     (setq q_ins_podval 0)
     (setq q_draw_rasst 0)
     (setq q_sel_uklon 0)
     (set_tile "mv" (rtos mv 2 0))
     (set_tile "mg" (rtos mg 2 0))
     (set_tile "usl_z" (rtos usl_z 2 2))
     (action_tile "mv" "(setq mv (get_tile \"mv\"))")
     (action_tile "mg" "(setq mg (get_tile \"mg\"))")
     (action_tile "usl_z" "(setq usl_z (get_tile \"usl_z\"))")
     (action_tile "xp" "(setq q_x (get_tile \"xp\"))")
     (action_tile "yp" "(setq q_y (get_tile \"yp\"))")
     (action_tile "zp" "(setq q_z (get_tile \"zp\"))")
     (action_tile "on_view" ; задать точку вставки
       "(if
    (eq q_xyz 1)
    (progn
    (mode_tile \"xp\" 0)
    (mode_tile \"yp\" 0)
    (mode_tile \"zp\" 0)
    (setq q_xyz 0)
    )
    (progn
    (mode_tile \"xp\" 1)
    (mode_tile \"yp\" 1)
    (mode_tile \"zp\" 1)
    (setq q_xyz 1)
    )
    )"
       )
     (action_tile "chek_v_pr"; учитывать вид профиля
       "(if (= q_chek_v_pr 0)
    (progn
    (mode_tile \"sel_v_pr\" 0)
    (mode_tile \"sel_uklon\" 1)
    (if (= q_ins_z 1) (mode_tile \"sel_str_z\" 0))
    (if (= q_draw_uklon 1) (mode_tile \"sel_uklon\" 1))
    (if (= q_sel_v_pr 3) (mode_tile \"draw_rasst\" 1)(mode_tile \"draw_rasst\" 0))
    (setq q_chek_v_pr 1)
    )
    (progn
    (mode_tile \"sel_v_pr\" 1)
    (mode_tile \"sel_uklon\" 0)
    (mode_tile \"sel_str_z\" 1)
    (if (= q_draw_uklon 1) (mode_tile \"sel_uklon\" 0)(mode_tile \"sel_uklon\" 1))
    (set_tile \"ins_podval\" \"0\")
    (setq q_ins_podval 0)
    (set_tile \"text_usl_z\" \"Отметка условного горизонта\")
    (set_tile \"usl_z\" (rtos usl_z 2 2))
    (mode_tile \"draw_rasst\" 0)
    (setq q_chek_v_pr 0)
    )
    )"
       )
     (action_tile "ins_z"; вставить отметки
       "(if (= q_chek_v_pr 1)
    (if (= q_ins_z 0)
    (progn
    (mode_tile \"sel_str_z\" 0)
    (setq q_ins_z 1)
    )
    (progn
    (mode_tile \"sel_str_z\" 1)
    (setq q_ins_z 0)
    )
    )
    (if (= q_ins_z 0)
    (setq q_ins_z 1)
    (setq q_ins_z 0)
    )
    )"
       )
     (action_tile "draw_uklon"; вставить уклон
       "(if (/= q_chek_v_pr 1)
    (if (= q_draw_uklon 0)
    (progn
    (mode_tile \"sel_uklon\" 0)
    (setq q_draw_uklon 1)
    )
    (progn
    (mode_tile \"sel_uklon\" 1)
    (setq q_draw_uklon 0)
    )
    )
    (if (= q_draw_uklon 0)
    (setq q_draw_uklon 1)
    (setq q_draw_uklon 0)
    )
    )"
       )
     (action_tile "ins_podval"; вставить подвал
       "(if (= q_chek_v_pr 0)
    (progn
    (set_tile \"chek_v_pr\" \"1\")
    (setq q_chek_v_pr 1)
    (mode_tile \"sel_v_pr\" 0)
    (if (= q_ins_z 1) (mode_tile \"sel_str_z\" 0))
    (if (= q_draw_uklon 1) (mode_tile \"sel_uklon\" 1))
    )
    )
    (if (= q_ins_podval 0)
    (progn
    (if (= q_sel_v_pr 3) (mode_tile \"draw_rasst\" 1)(mode_tile \"draw_rasst\" 0))
    (setq q_ins_podval 1)
    )
    (progn
    (set_tile \"text_usl_z\" \"Отметка условного горизонта\")
    (set_tile \"usl_z\" (rtos usl_z 2 2))
    (setq q_ins_podval 0)
    )
    )"
       )
     (action_tile "sel_v_pr"; выбор вида профиля формирование списка отметок
       "(cond
    ((= $value \"0\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли (люков)\" \"Отметка верха канала\" \"Ометка пола канала\" \"Отметка оси трубы\"))
    (end_list)
    (mode_tile \"draw_rasst\" 0)
    (setq q_sel_v_pr 0)
    )
   ((= $value \"1\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли (люков)\" \"Отметка верха трубы\" \"Ометка низа трубы\" \"Отметки оси трубы\"))
    (end_list)
    (mode_tile \"draw_rasst\" 0)
    (setq q_sel_v_pr 1)
    )
    ((= $value \"2\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли\" \"Проектные отметки земли\" \"Отметка верха трубы\"))
    (end_list)
    (mode_tile \"draw_rasst\" 0)
    (setq q_sel_v_pr 2)
    )
    ((= $value \"3\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли\" \"Проектные отметки земли\" \"Ометки обечайки колодцев\" \"Отметки лотков труб\"))
    (end_list)
    (mode_tile \"draw_rasst\" 1)
    (setq q_draw_rasst 0)
    (set_tile \"draw_rasst\" \"0\")
    (setq q_sel_v_pr 3)
    )
    ((= $value \"4\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли\" \"Отметка дна траншеи\" \"Отметка верха трубы\"))
    (end_list)
    (mode_tile \"draw_rasst\" 0)
    (setq q_sel_v_pr 4)
    )
    ((= $value \"5\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли (люков)\" \"Отметка верха канала\" \"Ометка пола канала\" \"Отметка оси трубы\" \"Ометки обечайки колодцев\" \"Отметки лотков труб\"))
    (end_list)
    (mode_tile \"draw_rasst\" 0)
    (setq q_sel_v_pr 5)
    )
    )"
       )
     (action_tile "sel_str_z"; выбор строки подписи отметок
       "(cond
    ((= $value \"0\")
    (setq q_sel_str_z 0)
    )
   ((= $value \"1\")
    (setq q_sel_str_z 1)
    )
    ((= $value \"2\")
    (setq q_sel_str_z 2)
    )
    ((= $value \"3\")
    (setq q_sel_str_z 3)
    )
    ((= $value \"4\")
    (setq q_sel_str_z 4)
    )
    ((= $value \"5\")
    (setq q_sel_str_z 5)
    )
    )"
       )
     (action_tile "draw_line"
       "(if (= q_draw_line 0)
    (setq q_draw_line 1)
    (setq q_draw_line 0)
    )"
       )
     (action_tile "sel_uklon"; выбор едениц уклона
       "(cond
    ((= $value \"0\")
    (setq q_sel_uklon 0)
    )
    ((= $value \"1\")
    (setq q_sel_uklon 1)
    )
    )"
       )
     (action_tile "draw_ugli"; вставить углы поворота
       "(if (= q_draw_ugli 0)
    (setq q_draw_ugli 1)
    (setq q_draw_ugli 0)
    )"
       )
     (action_tile "draw_rasst"; вставить углы расстояния
       "(if (= q_draw_rasst 0)
    (setq q_draw_rasst 1)
    (setq q_draw_rasst 0)
    )"
       )
     (action_tile "draw_pr"; рисовать линию профиля
       "(if (= q_draw_pr 0)
    (setq q_draw_pr 1)
    (setq q_draw_pr 0)
    )"
       )
     (action_tile "ins_m"; вставить маркеры
       "(if (= q_ins_m 0)
    (setq q_ins_m 1)
    (setq q_ins_m 0)
    )"
       )
     (if (eq (start_dialog) 0) (progn (unload_dialog dcl_id)(exit))(unload_dialog dcl_id))
     (if
       (not (or (eq (type mv) 'INT)(eq (type mv) 'REAL)))
       (setq mv (atof mv))
       )
     (if
       (not (or (eq (type mg) 'INT)(eq (type mg) 'REAL)))
       (setq mg (atof mg))
       )
     (if
       (not (or (eq (type usl_z) 'INT)(eq (type usl_z) 'REAL)))
       (setq usl_z (atof usl_z))
       )
     (if
       (= q_xyz 1)
       (setq t1! (get_pt1!))
       (setq t1! (list (atof q_x) (atof q_y) (atof q_z) ))
       )
     (setq t0! t1!)
  (setq min_z (+ usl_z 7))
  (setq max_z (+ usl_z 15))

     ;                    Вставляем Подвал
     (if (= q_ins_podval 1)
       (draw_profil_insert_block_podval q_sel_v_pr t1! mg mv min_z max_z usl_z 2Dpline)
       )
     

     ;                    Рисуем линии на профиле
     (if (= q_draw_line 1)
       (progn
	 (cond
	   ((= q_sel_v_pr 0)(setq t_do_linii(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg))))))
	   ((= q_sel_v_pr 1)(setq t_do_linii(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg))))))
	   ((= q_sel_v_pr 2)(setq t_do_linii(mapcar '- t0! (list 0 (/ 65 (/ 1000 mg))))))
	   ((= q_sel_v_pr 3)(setq t_do_linii(mapcar '- t0! (list 0 (/ 70 (/ 1000 mg))))))
	   ((= q_sel_v_pr 4)(setq t_do_linii(mapcar '- t0! (list 0 (/ 95 (/ 1000 mg))))))
	   ((= q_sel_v_pr 5)(setq t_do_linii(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg))))))
	   )
	 (if (= q_chek_v_pr 0)(progn (initget)(setq t_do_linii(getpoint "\nУкажи до куда будем опускать линии: "))))
	 )
       )
     ;                    Подписываем расстояния на профиле
     (if (= q_draw_rasst 1)
       (progn
	 (cond
	   ((= q_sel_v_pr 0)
	    (setq t1_draw_rasst(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg)))))
	    (setq t2_draw_rasst(mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
	    (setq ht (/ 3.5 (/ 1000 mg)))
	    (setq styl (getvar "TEXTSTYLE"))
	    )
	   ((= q_sel_v_pr 1)
	    (setq t1_draw_rasst(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg)))))
	    (setq t2_draw_rasst(mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
	    (setq ht (/ 3.5 (/ 1000 mg)))
	    (setq styl (getvar "TEXTSTYLE"))
	    )
	   ((= q_sel_v_pr 2)
	    (setq t1_draw_rasst(mapcar '- t0! (list 0 (/ 65 (/ 1000 mg)))))
	    (setq t2_draw_rasst(mapcar '- t0! (list 0 (/ 55 (/ 1000 mg)))))
	    (setq ht (/ 3.5 (/ 1000 mg)))
	    (setq styl (getvar "TEXTSTYLE"))
	    )
	   ((= q_sel_v_pr 4)
	    (setq t1_draw_rasst(mapcar '- t0! (list 0 (/ 115 (/ 1000 mg)))))
	    (setq t2_draw_rasst(mapcar '- t0! (list 0 (/ 105 (/ 1000 mg)))))
	    (setq ht (/ 2.5 (/ 1000 mg)))
	    (setq styl (getvar "TEXTSTYLE"))
	    )
	   ((= q_sel_v_pr 5)
	    (setq t1_draw_rasst(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg)))))
	    (setq t2_draw_rasst(mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
	    (setq ht (/ 3.5 (/ 1000 mg)))
	    (setq styl (getvar "TEXTSTYLE"))
	    )
	   )
	 (if (= q_chek_v_pr 0)
	   (progn
	     (initget)(setq t1_draw_rasst(getpoint "\nУкажи нижнюю линию строки расстояния: "))
	     (initget)(setq t2_draw_rasst(getpoint "\nУкажи верхнюю линию строки расстояния: "))
	     (setq ht (/ 3.5 (/ 1000 mg)))
	     (setq styl (getvar "TEXTSTYLE"))
	     )
	   )
	 
	 )
       )
     ;                               Вставка отметок
     (if (= q_ins_z 1)
       (progn
	 (if (= q_chek_v_pr 1)
	   (cond
	     ((= q_sel_v_pr 0) ; В канале
	      (cond
		((= q_sel_str_z 0); Факт.зем(люк)
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 25 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 10 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 1); Верх кан
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 40 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 25 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 2); Пол кан
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 55 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 40 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 3); Ось трубы
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 65 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		)
	      )
	     ((= q_sel_v_pr 1) ; ППУ
	      (cond
		((= q_sel_str_z 0); Факт.зем(люк)
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 25 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 10 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 1); Верх тр
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 40 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 25 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 2); Низ тр
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 55 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 40 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 3); Ось трубы
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 65 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		)
	      )
	     ((= q_sel_v_pr 2) ; Водопровод
	      (cond
		((= q_sel_str_z 0); Факт.зем
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 15 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 0 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 1); Проектн отм зем
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 30 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 15 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 2); Верх тр
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 45 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 30 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		)
	      )
	     ((= q_sel_v_pr 3) ; Канализация
	      (cond
		((= q_sel_str_z 0); Факт.зем
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 15 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 0 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 1); Проектн отм зем
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 30 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 15 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 2); отметка обич колодцев
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 45 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 30 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 3); отметка лотка труб
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 60 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 45 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		)
	      )
	     ((= q_sel_v_pr 4) ; Газопровод
	      (cond
		((= q_sel_str_z 0); Факт.зем
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 15 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 0 (/ 1000 mg)))))
		 (setq ht (/ 2.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 1); Отм дна траншеи
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 30 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 15 (/ 1000 mg)))))
		 (setq ht (/ 2.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 2); Верх тр
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 45 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 30 (/ 1000 mg)))))
		 (setq ht (/ 2.5 (/ 1000 mg)))
		 )
		)
	      )
	     ((= q_sel_v_pr 5) ; В канале + дренаж
	      (cond
		((= q_sel_str_z 0); Факт.зем(люк)
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 25 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 10 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 1); Верх кан
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 40 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 25 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 2); Пол кан
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 55 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 40 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 3); Ось трубы
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 65 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 4); обич кол
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 215 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 200 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		((= q_sel_str_z 5); отметка лотка труб
		 (setq t1_ins_z (mapcar '- t0! (list 0 (/ 230 (/ 1000 mg)))))
		 (setq t2_ins_z (mapcar '- t0! (list 0 (/ 215 (/ 1000 mg)))))
		 (setq ht (/ 3.5 (/ 1000 mg)))
		 )
		)
	      )
	     )
	   (progn
	     (initget)(setq t1_ins_z(getpoint "\nУкажи нижнюю линию строки отметок: "))
	     (initget)(setq t2_ins_z(getpoint "\nУкажи верхнюю линию строки отметок: "))
	     (setq ht (/ 3.5 (/ 1000 mg)))
	     )
	   )
	 )
       )
     ;                         Вставка длинна/наклон
     (if (= q_draw_uklon 1)
       (progn
	 (if (= q_chek_v_pr 1)
	   (cond
	     ((= q_sel_v_pr 0)
	      (setq t1_draw_uklon(mapcar '- t0! (list 0 (/ 105 (/ 1000 mg)))))
	      (setq t2_draw_uklon(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      (setq pro! 1)
	      (setq n_00 3)
	      )
	     ((= q_sel_v_pr 1)
	      (setq t1_draw_uklon(mapcar '- t0! (list 0 (/ 105 (/ 1000 mg)))))
	      (setq t2_draw_uklon(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      (setq pro! 1)
	      (setq n_00 3)
	      )
	     ((= q_sel_v_pr 2)
	      (setq t1_draw_uklon(mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
	      (setq t2_draw_uklon(mapcar '- t0! (list 0 (/ 65 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      (setq pro! 1)
	      (setq n_00 3)
	      )
	     ((= q_sel_v_pr 3)
	      (setq t1_draw_uklon(mapcar '- t0! (list 0 (/ 95 (/ 1000 mg)))))
	      (setq t2_draw_uklon(mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      (setq pro! 1)
	      (setq n_00 3)
	      )
	     ((= q_sel_v_pr 4)
	      (setq t1_draw_uklon(mapcar '- t0! (list 0 (/ 105 (/ 1000 mg)))))
	      (setq t2_draw_uklon(mapcar '- t0! (list 0 (/ 95 (/ 1000 mg)))))
	      (setq ht (/ 2.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      (setq pro! 1000)
	      (setq n_00 1)
	      )
	     ((= q_sel_v_pr 5)
	      (setq t1_draw_uklon(mapcar '- t0! (list 0 (/ 105 (/ 1000 mg)))))
	      (setq t2_draw_uklon(mapcar '- t0! (list 0 (/ 90 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      (setq pro! 1)
	      (setq n_00 3)
	      )
	     )
	   (progn
	     (initget)(setq t1_draw_uklon(getpoint "\nУкажи нижнюю линию строки уклонов: "))
	     (initget)(setq t2_draw_uklon(getpoint "\nУкажи верхнюю линию строки уклонов: "))
	     (setq ht (/ 3.5 (/ 1000 mg)))
	     (cond
	       ((= q_sel_uklon 0)
		(setq styl (getvar "TEXTSTYLE"))
		(setq pro! 1)
		(setq n_00 3)
		)
	       ((= q_sel_uklon 1)
		(setq styl (getvar "TEXTSTYLE"))
		(setq pro! 1000)
		(setq n_00 1)
		)
	       )
	     )
	   )
	 )
       )

  (setq t0 t0!)
  (initget 1)(setq z1 (getreal "\nВведи начальную отметку: "))
  (setq p1 (mapcar '+ t0 (list 0 (/ (- z1 usl_z) (/ (* mv (/ 1000 mg)) 1000)))))
  (if (= q_draw_line 1)
      (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 p1) (cons 11 (list (nth 0 p1)(nth 1 t_do_linii)))))
      )
  
  (if (= q_draw_uklon 1)
    (entmake (list '(0 . "LINE") '(6 . "Continuous")
		   (cons 10 (list (nth 0 t0)(nth 1 t2_draw_uklon)))
		   (cons 11 (list (nth 0 t0)(nth 1 t1_draw_uklon))))
	     )
    )
  (if (= q_ins_z 1)
      (entmake (list '(0 . "TEXT")
		     (cons 10 p1)
		     '(72 . 1) '(73 . 1)
		     (cons 11 (list(nth 0 p1)(+(nth 1 t1_ins_z)(/(- (nth 1 t2_ins_z)(nth 1 t1_ins_z))2))))
		     (cons 40 ht)
		     (cons 50 (/ pi 2))
		     (cons 1 (rtos z1 2 2))
		     (cons 7 (getvar "TEXTSTYLE"))))
      )
  (if (= q_ins_m 1)
    (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")
		   '(90 . 3) '(70 . 1) (cons 43 0)
		   (cons 10 (mapcar '+ p1 (list -1.25 -2.165)))
		   (cons 10 p1)
		   (cons 10 (mapcar '+ p1 (list 1.25 -2.165)))))
      )
  (initget 4)(setq d2 (getreal "\nВведи длинну: "))
  (if d2
    (progn
      (if (= q_ins_podval 1)
	(mapcar '(lambda (x)
		   (setq x (entget x))
		   (entmod (subst (cons 11 (mapcar '+ (cdr(assoc 11 x)) (list d2 0)))(assoc 11 x) x))
		   (entupd (cdr(assoc -1 x)))
		   )
		sp_lin
		)
	)
      (initget 1)(setq z2 (getreal "\nВведи отметку: "))
      ))
  
  (while (not(eq d2 nil))
    (setq t0 (mapcar '+ t0 (list d2 0 0)))
    (setq p2 (mapcar '+ t0 (list 0 (/ (- z2 usl_z) (/ (* mv (/ 1000 mg)) 1000)))))

    
    (if (= q_draw_line 1)
      (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 p2) (cons 11 (list (nth 0 p2)(nth 1 t_do_linii)))))
      )
    
    (if (= q_draw_rasst 1)
      (progn
	(setq s (rtos d2 2 2))
	(setq hs (- (nth 1 t2_draw_rasst)(nth 1 t1_draw_rasst)))
	(if (/= d2 0)
	  (progn
	    (if (eq p1 nil)(setq p1 (mapcar '- t0 (list d2 0 ))))
	    (setq t1 (list (nth 0 p1) (nth 1 t1_draw_rasst)))
	    (setq t2 (list (nth 0 p2) (nth 1 t1_draw_rasst)))
	    (if
	      (>
		(+ (/ 1.6 (/ 1000 mg))(/ (* 1.6 (/ 2 3)) (/ 1000 mg)))
		(distance t1 t2)); условие
	      (progn
		(setq t3 (mapcar '+ t1 (list (/(distance t1 t2)2) (/ hs 4) )))
		(setq list_points (list t3 (mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ -7 (/ 1000 mg))))))
		(setq pt_array (convert_coords_list_from_safearray_mleader list_points))
		(setvar "CMLEADERSTYLE" "Подписи")
		(setq mleader_obj (vla-addmleader model_spece pt_array 0))
		(vla-put-StyleName mleader_obj "Подписи")
		(vla-put-textstring mleader_obj S)
		(vla-put-TextHeight mleader_obj (/ 2.5 (/ 1000 mg)))
		)
	      (progn
		(if
		  (< (+(calculation_str_long_be_h_stile S ht styl)(/ (* 1.6(/ 2 3)) (/ 1000 mg))) (distance t1 t2))
		  (progn
		    (setq ht (/ 3.5 (/ 1000 mg)))
		    (setq ang 0)
		    )
		  (progn
		    (setq ang (/ pi 2))
		    (if
		      (< (+(/ 3.5 (/ 1000 mg))(/ (* 3.5 0.6) (/ 1000 mg)))(distance t1 t2))
		      (setq ht (/ 3.5 (/ 1000 mg)))
		      (setq ht (* (distance t1 t2) 0.6))
		      )
		    )
		  ); if
		(entmake (list '(0 . "TEXT")
			       (cons 10 t1)
			       '(72 . 4)
			       (cons 11 (mapcar '+ t1 (list (/(distance t1 t2)2) (/ hs 2) )))
			       (cons 40 ht)
			       (cons 50 ang)
			       (cons 1 S)
			       (cons 7 styl)
			       )
			 )
		); progn
	      ); if
	    (if (= q_sel_v_pr 4)(entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (list (nth 0 t0)(nth 1 t1_draw_rasst)0)) (cons 11 (list (nth 0 t0)(nth 1 t2_draw_rasst)0)))))
	    )
	  )
	)
      )
    
    
    (if (= q_ins_z 1)
      (progn
      	   (cond
	     ((> (*(-(nth 0 p2)(nth 0 p1))0.6) ht)
	      (setq htz ht))
	     ((< (*(-(nth 0 p2)(nth 0 p1))0.6) (/ 1.6 (/ 1000 mg)))
	      (setq htz (/ 1.6 (/ 1000 mg))))
	     (T
	      (setq htz (*(-(nth 0 p2)(nth 0 p1))0.6)))
	     )
	   (setq z (+(*(- (nth 1 p2) (nth 1 t0!))(/ (* mv (/ 1000 mg)) 1000))usl_z))
	   (entmake (list '(0 . "TEXT")
			    (cons 10 p2)
			    '(72 . 1) '(73 . 1)
			    (cons 11 (list(nth 0 p2)(+(nth 1 t1_ins_z)(/(- (nth 1 t2_ins_z)(nth 1 t1_ins_z))2))))
			    (cons 40 htz)
			    (cons 50 (/ pi 2))
			    (cons 1 (rtos z 2 2))
			    (cons 7 styl)))
      )
      )
    
    (if (= q_draw_uklon 1)
      (progn
	(if
	  (/= d2 0)
	  (progn
	    (if (eq p1 nil)(setq p1 (mapcar '- t0 (list d2 0 ))))
	    (setq hs (- (nth 1 t2_draw_uklon)(nth 1 t1_draw_uklon)))
	    (setq s d2)
	    (setq pro(rtos (abs(*(/(- z1 z2) d2) pro!)) 2 n_00))
	    (setq t1 (list (nth 0 p1)(nth 1 t1_draw_uklon)))
	    (setq t2 (list (nth 0 p2)(nth 1 t1_draw_uklon)))
	    (setq H1 z1)
	    (setq H2 z2)
	    (setq t11 (mapcar '+ (list(nth 0 p1)(nth 1 t1_draw_uklon)) (list 0 hs)))
	    (setq t1- (mapcar '+ (list(nth 0 p1)(nth 1 t1_draw_uklon)) (list 0 (/ hs 2))))
	    (setq t22 (mapcar '+ (list(nth 0 p2)(nth 1 t1_draw_uklon)) (list 0 hs)))
	    (setq t2- (mapcar '+ (list(nth 0 p2)(nth 1 t1_draw_uklon)) (list 0 (/ hs 2))))
	    (cond
	      ((= H1 H2); -
	       (entmake (list '(0 . "LINE") '(6 . "Continuous") (append '(10) t1-) (append '(11) t2-)))
	       (if
		 (>
		   (+ (/ 1.6 (/ 1000 mg))(/ (* 1.6 (/ 2 3)) (/ 1000 mg)))
		   (distance t1- t2-)); условие
		 (progn
		   (setq t3 (mapcar '+ t11 (list (/(distance t1 t2)2) (/ (distance t1- t11) -4) )))
		   (draw_mleader_vla model_spece "0.0"(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ 7 (/ 1000 mg)))))
		   )
		 (progn
		   (if
		     (< (+(calculation_str_long_be_h_stile "0.0" ht styl)(/ (* 1.6(/ 2 3)) (/ 1000 mg))) (distance t1- t2-))
		     (progn
		       (setq ht (/ 3.5 (/ 1000 mg)))
		       (setq ang 0)
		       )
		     (progn
		       (setq ang (/ pi 2))
		       (if
			 (< (+(/ 3.5 (/ 1000 mg))(/ (* 3.5 0.6) (/ 1000 mg)))(distance t1- t2-))
			 (setq ht (/ 3.5 (/ 1000 mg)))
			 (setq ht (* (distance t1- t2-) 0.6))
			 )
		       )
		     ); if
		   (entmake (list '(0 . "TEXT")
				  (cons 10 t1)
				  '(72 . 4)
				  (cons 11 (mapcar '+ t1- (list (/(distance t1- t2-)2) (/ (distance t1 t1-) 2) )))
				  (cons 40 ht)
				  (cons 50 ang)
				  (cons 1 "0.0")
				  (cons 7 styl)
				  )
			    )
		   ); progn
		 ); if
	       (if
		 (>
		   (+ (/ 1.6 (/ 1000 mg))(/ (* 1.6 (/ 2 3)) (/ 1000 mg)))
		   (distance t1 t2)); условие
		 (progn
		   (setq t3 (mapcar '+ t1 (list (/(distance t1 t2)2) (/ (distance t1 t1-) 4) )))
		   (draw_mleader_vla model_spece (rtos S 2 2)(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ -7 (/ 1000 mg)))))
		   )
		 (progn
		   (if
		     (< (+(calculation_str_long_be_h_stile (rtos S 2 2) ht styl)(/ (* 1.6(/ 2 3)) (/ 1000 mg))) (distance t1 t2))
		     (progn
		       (setq ht (/ 3.5 (/ 1000 mg)))
		       (setq ang 0)
		       )
		     (progn
		       (setq ang (/ pi 2))
		       (if
			 (< (+(/ 3.5 (/ 1000 mg))(/ (* 3.5 0.6) (/ 1000 mg)))(distance t1 t2))
			 (setq ht (/ 3.5 (/ 1000 mg)))
			 (setq ht (* (distance t1 t2) 0.6))
			 )
		       )
		     ); if
		   (entmake (list '(0 . "TEXT")
				  (cons 10 t1)
				  '(72 . 4)
				  (cons 11 (mapcar '+ t1 (list (/(distance t1 t2)2) (/ (distance t1 t1-) 2) )))
				  (cons 40 ht)
				  (cons 50 ang)
				  (cons 1 (rtos S 2 2))
				  (cons 7 styl)
				  )
			    )
		   ); progn
		 ); if
	       )
	      ((> H1 H2); \
	       (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 t11) (cons 11 t2)))
	       (if (>(calculation_h_text_in_triang t1 t11 t2 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl))
		     (calculation_h_text_in_triang t1 t2 t11 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl))
		     )
		 (cond
		   ((> (*(calculation_h_text_in_triang t1 t11 t2 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8) (/ 3.5 (/ 1000 mg)))
		    (entmake (list '(0 . "TEXT")  '(72 . 0) '(73 . 0)
				   (cons 10 (mapcar '+ t1 (list (/(/ 3.5 (/ 1000 mg))3) (/(/ 3.5 (/ 1000 mg))3) )))
				   (cons 40 (/ 3.5 (/ 1000 mg)))
				   (cons 50 0)
				   (cons 1 (rtos S 2 2)) (cons 7 styl)))
		    )
		   ((< (*(calculation_h_text_in_triang t1 t11 t2 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8) (/ 1.6 (/ 1000 mg)))
		    (setq t3 (mapcar '+ t1 (list (/(distance t1 t2)2) (/ 1 (/ 1000 mg)) )))
		    (draw_mleader_vla model_spece (rtos S 2 2)(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ -7 (/ 1000 mg)))))
		    )
		   (T
		    (entmake (list '(0 . "TEXT")  '(72 . 0) '(73 . 0)
				   (cons 10 (mapcar '+ t1 (list
							    (/(*(calculation_h_text_in_triang t1 t11 t2 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8)3)
							    (/(*(calculation_h_text_in_triang t1 t11 t2 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8)3)
							    )))
				   (cons 40 (*(calculation_h_text_in_triang t1 t11 t2 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8))
				   (cons 50 0)
				   (cons 1 (rtos S 2 2)) (cons 7 styl)))
		    )
		   )
		 (cond
		   ((> (*(calculation_h_text_in_triang t1 t2 t11 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8) (/ 3.5 (/ 1000 mg)))
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 0) '(73 . 3)
				   (cons 11 (mapcar '+ t1 (list (/(/ 3.5 (/ 1000 mg))3) (/(/ 3.5 (/ 1000 mg))3) )))
				   (cons 40 (/ 3.5 (/ 1000 mg)))
				   (cons 50 (/ pi 2))
				   (cons 1 (rtos S 2 2)) (cons 7 styl)))
		    )
		   ((< (*(calculation_h_text_in_triang t1 t2 t11 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8) (/ 1.6 (/ 1000 mg)))
		    
		    (setq t3 (mapcar '+ t1 (list (/(distance t1 t2)2) (/ 1 (/ 1000 mg)) )))
		    (draw_mleader_vla model_spece (rtos S 2 2)(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ -7 (/ 1000 mg)))))
		    )
		   (T
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 0) '(73 . 3)
				   (cons 11 (mapcar '+ t1 (list
							    (/(*(calculation_h_text_in_triang t1 t2 t11 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8)3)
							    (/(*(calculation_h_text_in_triang t1 t2 t11 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8)3)
							    )))
				   (cons 40 (*(calculation_h_text_in_triang t1 t2 t11 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8))
				   (cons 50 (/ pi 2))
				   (cons 1 (rtos S 2 2)) (cons 7 styl)))
		    )
		   )
		 )
	       (if (>(calculation_h_text_in_triang t22 t2 t11 (calculation_text_ratio_h_for_dlin pro ht styl))
		     (calculation_h_text_in_triang t22 t11 t2 (calculation_text_ratio_h_for_dlin pro ht styl))
		     )
		 (cond
		   ((> (*(calculation_h_text_in_triang t22 t2 t11 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8) (/ 3.5 (/ 1000 mg)))
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 2) '(73 . 3)
				   (cons 11 (mapcar '- t22 (list (/(/ 3.5 (/ 1000 mg))3) (/(/ 3.5 (/ 1000 mg))3) )))
				   (cons 40 (/ 3.5 (/ 1000 mg)))
				   (cons 50 0)
				   (cons 1 pro) (cons 7 styl)))
		    )
		   ((< (*(calculation_h_text_in_triang t22 t2 t11 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8) (/ 1.6 (/ 1000 mg)))
		    (setq t3 (mapcar '- t22 (list (/(distance t1 t2)2) (/ 1 (/ 1000 mg)) )))
		    (draw_mleader_vla model_spece pro(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ 7 (/ 1000 mg)))))
		    )
		   (T
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 2) '(73 . 3)
				   (cons 11 (mapcar '- t22 (list
							     (/(*(calculation_h_text_in_triang t22 t2 t11 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8)3)
							     (/(*(calculation_h_text_in_triang t22 t2 t11 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8)3)
							     )))
				   (cons 40 (*(calculation_h_text_in_triang t22 t2 t11 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8))
				   (cons 50 0)
				   (cons 1 pro) (cons 7 styl)))
		    )
		   )
		 (cond
		   ((> (*(calculation_h_text_in_triang t22 t11 t2 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8) (/ 3.5 (/ 1000 mg)))
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 2) '(73 . 0)
				   (cons 11 (mapcar '- t22 (list (/(/ 3.5 (/ 1000 mg))3) (/(/ 3.5 (/ 1000 mg))3) )))
				   (cons 40 (/ 3.5 (/ 1000 mg)))
				   (cons 50 (/ pi 2))
				   (cons 1 pro) (cons 7 styl)))
		    )
		   ((< (*(calculation_h_text_in_triang t22 t11 t2 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8) (/ 1.6 (/ 1000 mg)))
		    (setq t3 (mapcar '- t22 (list (/(distance t1 t2)2) (/ 1 (/ 1000 mg)) )))
		    (draw_mleader_vla model_spece pro(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ 7 (/ 1000 mg)))))
		    )
		   (T
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 2) '(73 . 0)
				   (cons 11 (mapcar '- t22 (list
							     (/(*(calculation_h_text_in_triang t22 t11 t2 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8)3)
							     (/(*(calculation_h_text_in_triang t22 t11 t2 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8)3)
							     )))
				   (cons 40 (*(calculation_h_text_in_triang t22 t11 t2 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8))
				   (cons 50 (/ pi 2))
				   (cons 1 pro) (cons 7 styl)))
		    )
		   )
		 )
	       )
	      ((< H1 H2); /
	       (entmake (list '(0 . "LINE") '(6 . "Continuous") (append '(10) t1) (append '(11) t22)))
	       (if (>(calculation_h_text_in_triang t2 t22 t1 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl))
		     (calculation_h_text_in_triang t2 t1 t22 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl))
		     )
		 (cond
		   ((> (*(calculation_h_text_in_triang t2 t22 t1 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8) (/ 3.5 (/ 1000 mg)))
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 2) '(73 . 0)
				   (cons 11 (mapcar '+ t2 (list (/(/ -3.5 (/ 1000 mg))3) (/(/ 3.5 (/ 1000 mg))3) )))
				   (cons 40 (/ 3.5 (/ 1000 mg)))
				   (cons 50 0)
				   (cons 1 (rtos S 2 2)) (cons 7 styl)))
		    )
		   ((< (*(calculation_h_text_in_triang t2 t22 t1 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8) (/ 1.6 (/ 1000 mg)))
		    (setq t3 (mapcar '+ t2 (list (/(distance t1 t2)2) (/ -1 (/ 1000 mg)) )))
		    (draw_mleader_vla model_spece (rtos S 2 2)(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ -7 (/ 1000 mg)))))
		    )
		   (T
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 2) '(73 . 0)
				   (cons 11 (mapcar '+ t2 (list
							    (/(*(calculation_h_text_in_triang t2 t22 t1 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) -0.8)3)
							    (/(*(calculation_h_text_in_triang t2 t22 t1 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8)3)
							    )))
				   (cons 40 (*(calculation_h_text_in_triang t2 t22 t1 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8))
				   (cons 50 0)
				   (cons 1 (rtos S 2 2)) (cons 7 styl)))
		    )
		   )
		 (cond
		   ((> (*(calculation_h_text_in_triang t2 t1 t22 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8) (/ 3.5 (/ 1000 mg)))
		    (entmake (list '(0 . "TEXT")  '(72 . 0) '(73 . 0)
				   (cons 10 (mapcar '+ t2 (list (/(/ -3.5 (/ 1000 mg))3) (/(/ 3.5 (/ 1000 mg))3) )))
				   (cons 40 (/ 3.5 (/ 1000 mg)))
				   (cons 50 (/ pi 2))
				   (cons 1 (rtos S 2 2)) (cons 7 styl)))
		    )
		   ((< (*(calculation_h_text_in_triang t2 t1 t22 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8) (/ 1.6 (/ 1000 mg)))
		    (setq t3 (mapcar '- t2 (list (/(distance t1 t2)2) (/ -1 (/ 1000 mg)) )))
		    (draw_mleader_vla model_spece (rtos S 2 2)(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ -7 (/ 1000 mg)))))
		    )
		   (T
		    (entmake (list '(0 . "TEXT")  '(72 . 0) '(73 . 0)
				   (cons 10 (mapcar '+ t2 (list
							    (/(*(calculation_h_text_in_triang t2 t1 t22 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) -0.8)3)
							    (/(*(calculation_h_text_in_triang t2 t1 t22 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8)3)
							    )))
				   (cons 40 (*(calculation_h_text_in_triang t2 t1 t22 (calculation_text_ratio_h_for_dlin (rtos S 2 2) ht styl)) 0.8))
				   (cons 50 (/ pi 2))
				   (cons 1 (rtos S 2 2)) (cons 7 styl)))
		    )
		   )
		 )
	       (if (>(calculation_h_text_in_triang t11 t1 t22 (calculation_text_ratio_h_for_dlin pro ht styl))
		     (calculation_h_text_in_triang t11 t22 t1 (calculation_text_ratio_h_for_dlin pro ht styl))
		     )
		 (cond
		   ((> (*(calculation_h_text_in_triang t11 t1 t22 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8) (/ 3.5 (/ 1000 mg)))
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 0) '(73 . 3)
				   (cons 11 (mapcar '+ t11 (list (/(/ 3.5 (/ 1000 mg))3) (/(/ -3.5 (/ 1000 mg))3) )))
				   (cons 40 (/ 3.5 (/ 1000 mg)))
				   (cons 50 0)
				   (cons 1 pro) (cons 7 styl)))
		    )
		   ((< (*(calculation_h_text_in_triang t11 t1 t22 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8) (/ 1.6 (/ 1000 mg)))
		    (setq t3 (mapcar '+ t11 (list (/(distance t1 t2)2) (/ -1 (/ 1000 mg)) )))
		    (draw_mleader_vla model_spece pro(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ 7 (/ 1000 mg)))))
		    )
		   (T
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 0) '(73 . 3)
				   (cons 11 (mapcar '+ t11 (list
							     (/(*(calculation_h_text_in_triang t11 t1 t22 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8)3)
							     (/(*(calculation_h_text_in_triang t11 t1 t22 (calculation_text_ratio_h_for_dlin pro ht styl)) -0.8)3)
							     )))
				   (cons 40 (*(calculation_h_text_in_triang t11 t1 t22 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8))
				   (cons 50 0)
				   (cons 1 pro) (cons 7 styl)))
		    )
		   )
		 (cond
		   ((> (*(calculation_h_text_in_triang t11 t22 t1 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8) (/ 3.5 (/ 1000 mg)))
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 2) '(73 . 3)
				   (cons 11 (mapcar '+ t11 (list (/(/ 3.5 (/ 1000 mg))3) (/(/ -3.5 (/ 1000 mg))3) )))
				   (cons 40 (/ 3.5 (/ 1000 mg)))
				   (cons 50 (/ pi 2))
				   (cons 1 pro) (cons 7 styl)))
		    )
		   ((< (*(calculation_h_text_in_triang t11 t22 t1 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8) (/ 1.6 (/ 1000 mg)))
		    (setq t3 (mapcar '+ t11 (list (/(distance t1 t2)2) (/ -1 (/ 1000 mg)) )))
		    (draw_mleader_vla model_spece pro(/ 2.5 (/ 1000 mg)) t3(mapcar '+ t3 (list (/ 2 (/ 1000 mg)) (/ 7 (/ 1000 mg)))))
		    )
		   (T
		    (entmake (list '(0 . "TEXT") (cons 10 t1) '(72 . 2) '(73 . 3)
				   (cons 11 (mapcar '+ t11 (list
							     (/(*(calculation_h_text_in_triang t11 t22 t1 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8)3)
							     (/(*(calculation_h_text_in_triang t11 t22 t1 (calculation_text_ratio_h_for_dlin pro ht styl)) -0.8)3)
							     )))
				   (cons 40 (*(calculation_h_text_in_triang t11 t22 t1 (calculation_text_ratio_h_for_dlin pro ht styl)) 0.8))
				   (cons 50 (/ pi 2))
				   (cons 1 pro) (cons 7 styl)))
		    )
		   )
		 )
	       )
	      )
	   (entmake (list '(0 . "LINE") '(6 . "Continuous")
			  (cons 10 (list (nth 0 t0)(nth 1 t2_draw_uklon)))
			  (cons 11 (list (nth 0 t0)(nth 1 t1_draw_uklon))))
		    )
	    )
	  )
	)
      )
    (if (= q_draw_pr 1)
      (if (eq pline nil)
	(progn
	  (entmake(list
		    '(0 . "LWPOLYLINE")
		    '(100 . "AcDbEntity")
		    '(100 . "AcDbPolyline")
		    (cons 90 2)
		    (cons 43 0.0)
		    (cons 70 0)
		    (cons 10 p1)
		    (cons 10 p2)
		    )
		  )
	  (setq pline (entlast))
	  (entupd pline)
	  )
	(progn
	  (setq dxf (entget pline))
	  (setq dxf (subst (cons 90 (1+ (cdr(assoc 90 dxf))))(assoc 90 dxf) dxf))
	  (entmod (append dxf (list (cons 10 p2))))
	  (entupd pline)
	  )
	)
      )
    
    (if (= q_ins_m 1)
    (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")
		   '(90 . 3) '(70 . 1) (cons 43 0)
		   (cons 10 (mapcar '+ p2 (list -1.25 -2.165)))
		   (cons 10 p2)
		   (cons 10 (mapcar '+ p2 (list 1.25 -2.165)))))
      )
    (setq d1 d2)
    (setq z1 z2)
    (setq p1 p2)
    (initget 4)(setq d2 (getreal "\nВведи длинну: "))
    (if d2
      (progn
	(if (= q_ins_podval 1)
	  (mapcar '(lambda (x)
		   (setq x (entget x))
		   (entmod (subst (cons 11 (mapcar '+ (cdr(assoc 11 x)) (list d2 0)))(assoc 11 x) x))
		   (entupd (cdr(assoc -1 x)))
		   )
		sp_lin
		)
	  )
	(initget 1)(setq z2 (getreal "\nВведи отметку: "))
	))
    );while
  (princ)
  )
