(defun C:draw_dist_and_downgrade_to_profile ( / text1 text2 t1 t2 t11 t1- t22 t2- H1 H2 h Y_N); Рисует направление превышения расстояние и наклон
(geo_tools-help "draw_dist_and_downgrade_to_profile")
  (initget "1 2")(setq Y_N (getkword "\nКакой набор? [1/2] <1>: "))
  (if (= Y_N nil)
    (setq Y_N "1")
    )
  (load_global_variable)
  (setq mv (file_dat_r_g_w "r" "mv" nil))
  (setq mg (file_dat_r_g_w "r" "mg" nil))
  (setq usl_z (file_dat_r_g_w "r" "usl_z" nil))
  (initget)(setq text1 (car (entsel "\nВыбери первый текст с отметкой: ")))
  (initget)(setq text2 (car (entsel "\nВыбери второй текст с отметкой: ")))
  (setq t1(get_p_usl_z_m_mg"\nУкажи точку #1 "))
  (initget)(setq t2(getpoint "\nУкажи точку #2: "))
  (setq H1 (atof (cdr (assoc 1 (entget text1)))))
  (setq H2 (atof (cdr (assoc 1 (entget text2)))))
  (setq h (- H1 H2))
  (setq S (distance t1 t2))
  (setq ht (/ 3.5 (/ 1000 mg)))
  (setq pro (rtos (abs(/ h S)) 2 3))
  ;;;  (setq pro (rtos (abs(*(/ h S) 1000)) 2 1))
  (setq hs (/ 15 (/ 1000 mg)))
  (setq styl (getvar "TEXTSTYLE"))
  (setq t11 (mapcar '+ t1 (list 0 hs)))
  (setq t1- (mapcar '+ t1 (list 0 (/ hs 2))))
  (setq t22 (mapcar '+ t2 (list 0 hs)))
  (setq t2- (mapcar '+ t2 (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)))
	  )
	 )
       )
     )
    )
  (princ)
  )
