(defun C:draw_profile_be_3dpoly   ; По 3Dполилинии строится линия профиля, отметки берутся из Z координаты вершин полилинии
       (/ t1 t2 t3 p1 p2 p3 n pl_prof t0 t0- ht styl z tp dcl_id a b g tt ttt
	q_xyz
	q_x
	q_y
	q_z
	q_ins_podval   ; вставить подвал
	q_ins_z        ; вставить отметку
	q_sel_str_z    ; выбор строки вставки отметки
	q_sel_v_pr     ; выбор вида профиля
	q_draw_uklon   ; вставить уклон
	q_draw_line    ; вставить линии
	q_draw_rasst   ; вставить расстояния
	q_draw_ugli    ; вставить углы поворота
	q_chek_v_pr    ; учитывать вида профиля
	q_sel_str_z    ; выбор едениц уклона
	q_start
	q_optim_z
	q_draw_points
	x
	sp_z
	t1_draw_rasst
	t2_draw_rasst
	t1_draw_ugli
	t2_draw_ugli
	t1_ins_z
	t2_ins_z
	t1_draw_points
	t2_draw_points
	tp1
	tp2
	dist
	pro!
	n_00
	min_z
	max_z
	sp_z
	usl_z_v
	min_z
	max_z
	mid_z
	2Dpline
	pline
	pline_vla
	2Dpline_vla
	htz
	list_granic
	point_list
	nabor
	point_leaders_list
	vla-leader
	leaders_list
	ttemp
	plus 2d_draw_design_be_2dpoly_trace analysis_point_11 diskription gn ht leaders_list line line_type
	list_points max_z mg mleader_obj mv n n1 num_vinoska opisanie p pline pn point point10
	point_leaders_list pt_array p_start q_chek_v_pr q_draw_line q_draw_peres q_draw_points q_draw_rasst
	q_draw_ugli q_draw_uklon q_ins_podval q_ins_z q_optim_z q_sel_str_z q_sel_uklon q_sel_v_pr q_start
	q_x q_xyz q_y q_z spis spisok spisokv styl t0 t0! t1! t1_draw_points t2_draw_points ug usl_z usl_z_v vla_vinoska x
	)
  (geo_tools-help "draw_profile_be_3dpoly")
  (load_global_variable)
  (setq pline (car (entsel "\nВыберите 3D полилинию: ")))
  (cond
    ((eq pline nil)
     (alert "Ничего не выбрано!"))
    ((not(eq (cdr(assoc 0 (entget pline))) "POLYLINE"))
     (alert "Выбрана не 3D полилиния!"))
    ((eq (cdr(assoc 0 (entget pline))) "POLYLINE")
     (setq pline_vla (vlax-ename->vla-object pline))
     (setq spisokv (extract_coord_polyline pline))
     (setq n (length spisokv))
     (repeat n
       (if (not (eq(nth 2 (car spisokv)) 0))
	 (setq sp_z
		(append sp_z(list(nth 2 (car spisokv))))
	       )
	 )
       (setq spisokv (cdr spisokv))
       )
     (setq min_z (apply 'min sp_z))
     (setq max_z (apply 'max sp_z))
     (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))
     (setq usl_z_v(- (fix min_z) 7))
     (setq dcl_id (geo-tools-load-dialog "d_profil"))
     (new_dialog "d_profil" dcl_id)
     (mode_tile "sel_v_pr" 1)
     (mode_tile "sel_str_z" 1)
     (mode_tile "sel_uklon" 1)
     (mode_tile "start" 1)
     (mode_tile "xp" 1)
     (mode_tile "yp" 1)
     (mode_tile "zp" 1)
     (mode_tile "optim_z" 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_xyz 1)
     (setq q_sel_v_pr 0)
     (setq q_ins_z 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_str_z 0)
     (setq q_draw_peres 0)
     (setq q_optim_z 0)
     (setq q_draw_points 0)
     (setq q_start 0)
     (setq 0plus 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" "(if (= q_ins_podval 0)(setq usl_z (get_tile \"usl_z\"))(setq usl_z_v (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 "0plus" "(setq 0plus (atof(get_tile \"0plus\")))")
     (action_tile "start" "(setq q_start (get_tile \"start\"))")
     (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))
    (if (= q_sel_v_pr 4) (mode_tile \"start\" 0)(mode_tile \"start\" 1))
    (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)
    (mode_tile \"start\" 1)
    (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)
    (mode_tile \"optim_z\" 0)
    )
    (progn
    (mode_tile \"sel_str_z\" 1)
    (setq q_ins_z 0)
    (mode_tile \"optim_z\" 1)
    )
    )
    (if (= q_ins_z 0)
    (progn
    (setq q_ins_z 1)
    (mode_tile \"optim_z\" 0)
    )
    (progn
    (setq q_ins_z 0)
    (mode_tile \"optim_z\" 1)
    )
    )
    )"
       )
     (action_tile "draw_uklon"; вставить уклон
       "(if (/= q_chek_v_pr 1)
    (if (= q_draw_uklon 0)
    (progn
    (mode_tile \"sel_draw_dist_and_downgrade_to_profile\" 0)
    (setq q_draw_uklon 1)
    )
    (progn
    (mode_tile \"sel_draw_dist_and_downgrade_to_profile\" 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
    (set_tile \"text_usl_z\" \"Отметка условного горизонта(вычислено)\")
    (set_tile \"usl_z\" (rtos usl_z_v 2 2))
    (if (= q_sel_v_pr 3) (mode_tile \"draw_rasst\" 1)(mode_tile \"draw_rasst\" 0))
    (if (= q_sel_v_pr 4) (mode_tile \"start\" 0)(mode_tile \"start\" 1))
    (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)
    (mode_tile \"start\" 1)
    (setq q_sel_v_pr 0)
    )
   ((= $value \"1\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли (люков)\" \"Отметка верха трубы\" \"Ометка низа трубы\" \"Отметки оси трубы\"))
    (end_list)
    (mode_tile \"draw_rasst\" 0)
    (mode_tile \"start\" 1)
    (setq q_sel_v_pr 1)
    )
    ((= $value \"2\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли\" \"Проектные отметки земли\" \"Отметка верха трубы\"))
    (end_list)
    (mode_tile \"draw_rasst\" 0)
    (mode_tile \"start\" 1)
    (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\")
    (mode_tile \"start\" 1)
    (setq q_sel_v_pr 3)
    )
    ((= $value \"4\")
    (start_list \"sel_str_z\")
    (mapcar 'add_list (list \"Фактические отметки земли\" \"Отметка дна траншеи\" \"Отметка верха трубы\"))
    (end_list)
    (setq q_start 0)
    (mode_tile \"draw_rasst\" 0)
    (set_tile \"start\" \"0\")
    (mode_tile \"start\" 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)
    (mode_tile \"start\" 1)
    (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_peres"; вставить пересечки
       "(if (= q_draw_peres 0)
    (setq q_draw_peres 1)
    (setq q_draw_peres 0)
    )"
       )
     (action_tile "optim_z"; оптимизировать расположение отметок
       "(if (= q_optim_z 0)
    (setq q_optim_z 1)
    (setq q_optim_z 0)
    )"
       )
     (action_tile "draw_points"; вставка подписей точек
       "(if (= q_draw_points 0)
    (setq q_draw_points 1)
    (setq q_draw_points 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
       (not (or (eq (type usl_z_v) 'INT)(eq (type usl_z_v) 'REAL)))
       (setq usl_z_v (atof usl_z_v))
       )
     (if
       (not (or (eq (type q_start) 'INT)(eq (type q_start) 'REAL)))
       (setq q_start (atof q_start))
       )
     (file_dat_r_g_w "w" "mv" mv)
     (file_dat_r_g_w "w" "mg" mg)
     (if (= q_ins_podval 1)
       (setq usl_z usl_z_v)
       )
     (file_dat_r_g_w "r" "usl_z" usl_z)
     (if
       (= q_xyz 1)
       (setq t1! (get_pt1!))
       (setq t1! (list (atof q_x) (atof q_y) (atof q_z) ))
       )
     (setq t0! (mapcar '+ t1! (list 0plus 0)))

     ;                    Рисуем полилинию профиля
     (setq spisokv (extract_coord_polyline pline))
     (setq n (length spisokv))
     (setq pl_prof (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")(cons 90 n) '(70 . 0) (cons 43 0)))
     (setq t0- t0!)
     (repeat n
       (setq p1 (car spisokv))
       (setq spisokv (cdr spisokv))
       (setq z (nth 2 p1))
       (setq tp (mapcar '+ t0- (list 0 (/(- z usl_z)(/ (* mv (/ 1000 mg)) 1000)))))
       (if (not (eq z 0))
	 (setq pl_prof(append pl_prof (list (cons 10 tp))))
	 )
       (if (> (length spisokv) 0)
	 (progn
	   (setq p2 (car spisokv))
	   (setq t0- (mapcar '+ t0- (list (distance (list (nth 0 p1) (nth 1 p1)) (list (nth 0 p2) (nth 1 p2))) 0 0)))
	   )
	 )
       )
     (entmake pl_prof)
     (setq 2Dpline (entlast))
     (setq 2Dpline_vla (vlax-ename->vla-object 2Dpline))
     ;                    Вставляем Подвал
     (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)
       (draw_profil_vertical_line q_sel_v_pr t0! mg 2Dpline)
       )
     ;                    Подписываем расстояния на профиле
     (if (= q_draw_rasst 1)
       (draw_profil_rasst 2Dpline t0! q_sel_v_pr mg)
       )
     ;                               Вставка отметок
     (if (= q_ins_z 1)
       (progn
	 (princ"\nВставляю отметки...")
	 (draw_profil_elevation q_chek_v_pr q_sel_v_pr t0! mg mv q_optim_z q_sel_str_z 2Dpline)
	 )
       )
     ;                         Вставка длинна/наклон
     (if (= q_draw_uklon 1)
       (draw_profil_downgrade q_chek_v_pr q_sel_v_pr t0! mg 2Dpline)
       )
     ;                         Вставка углов поворота
     (if (= q_draw_ugli 1)
       (progn
	 (if (= q_chek_v_pr 1)
	   (cond
	     ((= q_sel_v_pr 0)
	      (setq t1_draw_ugli(mapcar '- t0! (list 0 (/ 165 (/ 1000 mg)))))
	      (setq t2_draw_ugli(mapcar '- t0! (list 0 (/ 155 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      )
	     ((= q_sel_v_pr 1)
	      (setq t1_draw_ugli(mapcar '- t0! (list 0 (/ 165 (/ 1000 mg)))))
	      (setq t2_draw_ugli(mapcar '- t0! (list 0 (/ 155 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      )
	     ((= q_sel_v_pr 2)
	      (setq t1_draw_ugli(mapcar '- t0! (list 0 (/ 125 (/ 1000 mg)))))
	      (setq t2_draw_ugli(mapcar '- t0! (list 0 (/ 115 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      )
	     ((= q_sel_v_pr 3)
	      (setq t1_draw_ugli(mapcar '- t0! (list 0 (/ 80 (/ 1000 mg)))))
	      (setq t2_draw_ugli(mapcar '- t0! (list 0 (/ 70 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      )
	     ((= q_sel_v_pr 4)
	      (setq t1_draw_ugli(mapcar '- t0! (list 0 (/ 155 (/ 1000 mg)))))
	      (setq t2_draw_ugli(mapcar '- t0! (list 0 (/ 175 (/ 1000 mg)))))
	      (setq ht (/ 2.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      )
	     ((= q_sel_v_pr 5)
	      (setq t1_draw_ugli(mapcar '- t0! (list 0 (/ 165 (/ 1000 mg)))))
	      (setq t2_draw_ugli(mapcar '- t0! (list 0 (/ 155 (/ 1000 mg)))))
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      )
	     )
	   (progn
	     (initget)(setq t1_draw_ugli(getpoint "\nУкажи нижнюю линию строки углов поворота: "))
	     (initget)(setq t2_draw_ugli(getpoint "\nУкажи верхнюю линию строки углов поворота: "))
	     (setq ht (/ 3.5 (/ 1000 mg)))
	     (setq styl (getvar "TEXTSTYLE"))
	     )
	   )
	 (setq spisokv (extract_coord_polyline pline))
	 (setq n (- (length spisokv) 2))
	 (setq t0 (mapcar '+ t0! (list (distance (list (nth 0 (car spisokv)) (nth 1 (car spisokv))) (list (nth 0 (cadr spisokv)) (nth 1 (cadr spisokv)))) 0 0)))
	 (if (not(= q_sel_v_pr 4))
	   (repeat n
	     (setq p1 (car spisokv))
	     (setq spisokv (cdr spisokv))
	     (setq p2 (car spisokv))
	     (setq p3 (cadr spisokv))
	     (setq a (angle p2 p1))
	     (setq b (angle p2 p3))
	     (cond
	       ((> a b)
		(setq g (- a b)))
	       ((< a b)
		(setq g (-(* pi 2)(- b a))))
	       )
	     (if (not (and (< (- pi (/ pi 180)) g) (< g (+ pi (/ pi 180)))))
	       (cond
		 ((< g pi)
		  (entmake (list '(0 . "TEXT")
				 (cons 10 (mapcar '- (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli)))
						  (list (+ (calculation_str_long_be_h_stile (strcat (rtos (/ (if (> g pi) (- (* pi 2) g) g) (/ pi 180)) 2 0) "%%d") ht styl) (/ ht 4)) (/ ht 2))))
				 (cons 40 ht) (cons 1 (strcat (rtos (/ (if (> g pi) (- (* pi 2) g) g) (/ pi 180)) 2 0) "%%d")) (cons 7 styl)))
		  (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")
				 '(90 . 4)
				 '(40 . 0)
				 '(41 . 0)
				 (cons 10 (mapcar '- (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli)))
						  (list (+ (calculation_str_long_be_h_stile (strcat (rtos (/ (if (> g pi) (- (* pi 2) g) g) (/ pi 180)) 2 0) "%%d") ht styl) (/ ht 2)) (* ht 0.75))))
				 '(40 . 0)
				 '(41 . 0)
				 (cons 10 (mapcar '- (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli)))
						  (list 0 (* ht 0.75))))
				 '(40 . 0)
				 '(41 . 0)
				 (cons 10 (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli))))
				 (cons 40 (/ 1 (/ 1000 mg)))
				 '(41 . 0)
				 (cons 10 (mapcar '+ (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli))) (list 0 (* ht 0.75))))
				 )
			   )
		  )
		 ((> g pi)
		  (entmake (list '(0 . "TEXT")
				 (cons 10 (mapcar '- (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli)))
						  (list (+ (calculation_str_long_be_h_stile (strcat (rtos (/ (if (> g pi) (- (* pi 2) g) g) (/ pi 180)) 2 0) "%%d") ht styl) (/ ht 4)) (/ ht 2))))
				 (cons 40 ht) (cons 1 (strcat (rtos (/ (if (> g pi) (- (* pi 2) g) g) (/ pi 180)) 2 0) "%%d")) (cons 7 styl)))
		  (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")
				 '(90 . 4)
				 '(40 . 0)
				 '(41 . 0)
				 (cons 10 (mapcar '- (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli)))
						  (list (+ (calculation_str_long_be_h_stile (strcat (rtos (/ (if (> g pi) (- (* pi 2) g) g) (/ pi 180)) 2 0) "%%d") ht styl) (/ ht 2)) (* ht -0.75))))
				 '(40 . 0)
				 '(41 . 0)
				 (cons 10 (mapcar '+ (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli)))
						  (list 0 (* ht 0.75))))
				 '(40 . 0)
				 '(41 . 0)
				 (cons 10 (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli))))
				 (cons 40 (/ 1 (/ 1000 mg)))
				 '(41 . 0)
				 (cons 10 (mapcar '- (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli))) (list 0 (* ht 0.75))))
				 )
			   )
		  )
		 )
	       )
	     (setq t0 (mapcar '+ t0 (list (distance (list (nth 0 p2) (nth 1 p2)) (list (nth 0 p3) (nth 1 p3))) 0 0)))
	     )
	   (progn
	     (load_global_variable)
	     (setq spisokv (extract_coord_lwpolyline (entget 2Dpline)))
	     (setq n (length spisokv))
	     (setq dist (-(nth 0(nth (1- n) spisokv))(nth 0 (nth 0 spisokv))))
	     (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")
			    '(90 . 2)
			    (cons 43 (/ 0.5 (/ 1000 mg)))
			    (cons 10 (list (nth 0 t0!) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli))))
			    (cons 10 (mapcar '+
					     (list (nth 0 t0!) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli)))
					     (list dist 0)
					     )
				  )
			    )
		      )
	     (setq 2Dpline_vla (vlax-ename->vla-object (entlast)))
	     (if (eq q_start 0)
	       (setq n 1)
	       (setq n (1+(fix(/ q_start 100))))
	       )
	     (setq n1 1)
	     (setq p (vlax-curve-getStartPoint 2Dpline_vla)); нач пикет
	     (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")
			    '(90 . 2)
			    (cons 43 (/ 0.3 (/ 1000 mg)))
			    (cons 10 (polar p (/ pi 2)(/ 1.25 (/ 1000 mg))))
			    (cons 10 (polar p (* pi 1.5)(/ 1.25 (/ 1000 mg))))
			    ))
	     
	     (entmake (list '(0 . "LINE") '(6 . "Continuous")
			    (cons 10 (mapcar '+ p (list 0 (/ 35 (/ 1000 mg)))))
			    (cons 11 (mapcar '+ p (list 0 (/ 50 (/ 1000 mg)))))))
	     (entmake (list '(0 . "TEXT")
			    (cons 10 p)
			    '(72 . 4)
			    (cons 11 (mapcar '+ p (list (/ (* -2.5 0.75) (/ 1000 mg)) (/ 42.5 (/ 1000 mg)))))
			    (cons 40 ht)
			    (cons 50 (/ pi 2))
			    (cons 1 (strcat "ПК" (itoa(fix(/ q_start 100)))))
			    (cons 7 styl)))
	     (if (not(eq q_start 0))
	       (entmake (list '(0 . "TEXT")
			      (cons 10 p)
			      '(72 . 4)
			      (cons 11 (mapcar '+ p (list (/ (* 2.5 0.75) (/ 1000 mg)) (/ 42.5 (/ 1000 mg)))))
			      (cons 40 ht)
			      (cons 50 (/ pi 2))
			      (cons 1 (strcat "+"(rtos(rem q_start 100)2 1)))
			      (cons 7 styl)))
	       )
	     (setq list_points (list p(mapcar '+ p (list(/ -1 (/ 1000 mg)) (/ 5 (/ 1000 mg))))))
	     (setq pt_array (convert_coords_list_from_safearray_mleader list_points))
	     (setq mleader_obj (vla-addmleader model_spece pt_array 0))
	     (vla-put-StyleName mleader_obj "Подписи")
	     (vla-put-textstring mleader_obj (strcat "\\PПК"(itoa(fix(/ q_start 100)))"+"(rtos(rem q_start 100)2 1)))
	     (vla-put-TextHeight mleader_obj ht)
	     (repeat (fix(/(vla-get-length 2Dpline_vla)100))                                                                    ;пикетаж<
	       (setq p (vlax-curve-getPointAtDist 2Dpline_vla (-(* n1 100)(rem q_start 100))))
	       (setq pn (vlax-curve-getPointAtParam 2Dpline_vla(float(fix(vlax-curve-getParamAtPoint 2Dpline_vla p)))))
	       
	       (entmake (list '(0 . "LINE") '(6 . "Continuous")
			      (cons 10 (mapcar '+ p (list 0 (/ 35 (/ 1000 mg)))))
			      (cons 11 (mapcar '+ p (list 0 (/ 50 (/ 1000 mg)))))))
	       (entmake (list '(0 . "TEXT")
			      (cons 10 p)
			      '(72 . 4)
			      (cons 11 (mapcar '+ p (list (/ (* -2.5 0.75) (/ 1000 mg)) (/ 42.5 (/ 1000 mg)))))
			      (cons 40 ht)
			      (cons 50 (/ pi 2))
			      (cons 1 (strcat "ПК" (itoa n)))
			      (cons 7 styl)))
	       
	       (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")
			      '(90 . 2)
			      (cons 43 (/ 0.3 (/ 1000 mg)))
			      (cons 10 (polar p (/ pi 2)(/ 1.25 (/ 1000 mg))))
			      (cons 10 (polar p (* pi 1.5)(/ 1.25 (/ 1000 mg))))
			      ))
	       (entmake (list '(0 . "TEXT")
			      (cons 10 p)
			      '(72 . 4)
			      (cons 11 (polar p (/ pi 2)(/ (* 2.5 1.3) (/ 1000 mg))))
			      (cons 40 ht)
			      (cons 50 0)
			      (cons 1 (strcat "ПК" (itoa n)))
			      (cons 7 styl)))
	       (setq n (1+ n))
	       (setq n1 (1+ n1))
	       )                                                                                                                   ;пикетаж>
	     (setq p (vlax-curve-getEndPoint 2Dpline_vla)); кон пикет
	     (entmake (list '(0 . "LINE") '(6 . "Continuous")
			    (cons 10 (mapcar '+ p (list 0 (/ 35 (/ 1000 mg)))))
			    (cons 11 (mapcar '+ p (list 0 (/ 50 (/ 1000 mg)))))))
	     (entmake (list '(0 . "TEXT")
			    (cons 10 p)
			    '(72 . 4)
			    (cons 11 (mapcar '+ p (list (/ (* -2.5 0.75) (/ 1000 mg)) (/ 42.5 (/ 1000 mg)))))
			    (cons 40 ht)
			    (cons 50 (/ pi 2))
			    (cons 1 (strcat "ПК" (itoa(fix(/(+(vlax-curve-getDistAtPoint 2Dpline_vla p)q_start)100)))))
			    (cons 7 styl)))
	     (entmake (list '(0 . "TEXT")
			    (cons 10 p)
			    '(72 . 4)
			    (cons 11 (mapcar '+ p (list (/ (* 2.5 0.75) (/ 1000 mg)) (/ 42.5 (/ 1000 mg)))))
			    (cons 40 ht)
			    (cons 50 (/ pi 2))
			    (cons 1 (strcat "+"(rtos(rem(+(vlax-curve-getDistAtPoint 2Dpline_vla p)q_start)100)2 1)))
			    (cons 7 styl)))
	     (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(6 . "Continuous") '(100 . "AcDbPolyline")
			    '(90 . 2)
			    (cons 43 (/ 0.3 (/ 1000 mg)))
			    (cons 10 (polar p (/ pi 2)(/ 1.25 (/ 1000 mg))))
			    (cons 10 (polar p (* pi 1.5)(/ 1.25 (/ 1000 mg))))
			    ))
	     (setq list_points (list p(mapcar '+ p (list(/ 5 (/ 1000 mg)) (/ 5 (/ 1000 mg))))))
	     (setq pt_array (convert_coords_list_from_safearray_mleader list_points))
	     (setq mleader_obj (vla-addmleader model_spece pt_array 0))
	     (vla-put-StyleName mleader_obj "Подписи")
	     (vla-put-textstring mleader_obj (strcat "\\PПК"(itoa(fix(/(+(vlax-curve-getDistAtPoint 2Dpline_vla p)q_start)100)))
						     "+"(rtos(rem(+(vlax-curve-getDistAtPoint 2Dpline_vla p)q_start)100)2 1)))
	     (vla-put-TextHeight mleader_obj ht)
	     (setq spisokv (extract_coord_polyline pline))
	     (setq n (- (length spisokv) 2))
	     (setq t0 (mapcar '+ t0! (list (distance (list (nth 0 (car spisokv)) (nth 1 (car spisokv))) (list (nth 0 (cadr spisokv)) (nth 1 (cadr spisokv)))) 0 0)))
	     (setq p_start (vlax-curve-getStartPoint 2Dpline_vla))
	     (repeat n  ; подпись углов
	       (setq p1 (car spisokv))
	       (setq spisokv (cdr spisokv))
	       (setq p2 (car spisokv))
	       (setq p3 (cadr spisokv))
	       (setq a (angle p2 p1))
	       (setq b (angle p2 p3))
	       (cond
		 ((> a b)
		  (setq g (- a b)))
		 ((< a b)
		  (setq g (-(* pi 2)(- b a))))
		 )
	       (setq gn(if (minusp (- pi g))
			 (+(- pi g)(* pi 2))
			 (- pi g)
			 )
		     )
	       (setq p (list (nth 0 t0) (+(/(-(nth 1 t2_draw_ugli)(nth 1 t1_draw_ugli))2)(nth 1 t1_draw_ugli))))
	       (if (not (and (< (- pi (/ pi 180)) g) (< g (+ pi (/ pi 180)))))
		 (progn
		   (entmake (list '(0 . "TEXT")
				  (cons 10 p)
				  '(72 . 4)
				  (cons 11 (mapcar '- p (list (/ (distance p_start p) 2) (/ 5 (/ 1000 mg)))))
				  (cons 40 ht)
				  (cons 50 0)
				  (cons 1 (strcat "L="(rtos (distance p_start p) 2 1)"м"))
				  (cons 7 styl)))
		   (setq p_start p)
		   (setq list_points (list p(mapcar '+ p(list(/ -0.5 (/ 1000 mg)) (/ 5 (/ 1000 mg))))))
		   (setq pt_array (convert_coords_list_from_safearray_mleader list_points))
		   (setq mleader_obj (vla-addmleader model_spece pt_array 0))
		   (vla-put-StyleName mleader_obj "Подписи")
		   (vla-put-textstring mleader_obj (strcat "УП "(rtos(abs(/ (- g pi) (/ pi 180)))2 0)"%%d\\P"))
		   (vla-put-TextHeight mleader_obj ht)
		   (entmake (list '(0 . "LINE") '(6 . "Continuous")
				  (cons 10 (mapcar '+ p (list 0 (/ 35 (/ 1000 mg)))))
				  (cons 11 (mapcar '+ p (list 0 (/ 50 (/ 1000 mg)))))))
		   (entmake (list '(0 . "TEXT")
				  (cons 10 p)
				  '(72 . 4)
				  (cons 11 (mapcar '+ p (list (/ (* -2.5 0.75) (/ 1000 mg)) (/ 42.5 (/ 1000 mg)))))
				  (cons 40 ht)
				  (cons 50 (/ pi 2))
				  (cons 1 (strcat "+"(rtos(rem(+(vlax-curve-getDistAtPoint 2Dpline_vla p)q_start)100)2 1)))
				  (cons 7 styl)))
		   (cond
		     ((or(and (> gn 0) (< gn (/ pi 8)))(eq gn (/ pi 8)))
		      (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 p) (cons 11 (polar p (/ pi 12) (/ 6.5 (/ 1000 mg))))))
		      (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (polar p (/ pi 12) (/ 6.5 (/ 1000 mg))))
				     (cons 11 (polar (polar p (/ pi 12) (/ 6.5 (/ 1000 mg)))
						     (+(angle (polar p (/ pi 12) (/ 6.5 (/ 1000 mg))) p) (/ pi 4))
						     (/ 1.5 (/ 1000 mg))))))
		      (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (polar p (/ pi 12) (/ 6.5 (/ 1000 mg))))
				     (cons 11 (polar (polar p (/ pi 12) (/ 6.5 (/ 1000 mg)))
						     (-(angle (polar p (/ pi 12) (/ 6.5 (/ 1000 mg))) p) (/ pi 4))
						     (/ 1.5 (/ 1000 mg))))))
		      (vla-AddArc model_spece (vlax-3D-point p) (/ 3.5 (/ 1000 mg)) (-(* pi 2)(/ pi 12))(/ pi 6))
		      )
		     ((and (> gn (-(* pi 2)(/ pi 8))) (< gn (* pi 2)))
		      (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 p) (cons 11 (polar p (-(* pi 2)(/ pi 12)) (/ 6.5 (/ 1000 mg))))))
		      (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (polar p (-(* pi 2)(/ pi 12)) (/ 6.5 (/ 1000 mg))))
				     (cons 11 (polar (polar p (-(* pi 2)(/ pi 12)) (/ 6.5 (/ 1000 mg)))
						     (+(angle (polar p (-(* pi 2)(/ pi 12)) (/ 6.5 (/ 1000 mg))) p) (/ pi 4))
						     (/ 1.5 (/ 1000 mg))))))
		      (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (polar p (-(* pi 2)(/ pi 12)) (/ 6.5 (/ 1000 mg))))
				     (cons 11 (polar (polar p (-(* pi 2)(/ pi 12)) (/ 6.5 (/ 1000 mg)))
						     (-(angle (polar p (-(* pi 2)(/ pi 12)) (/ 6.5 (/ 1000 mg))) p) (/ pi 4))
						     (/ 1.5 (/ 1000 mg))))))
		      (vla-AddArc model_spece (vlax-3D-point p) (/ 3.5 (/ 1000 mg)) (-(* pi 2)(/ pi 6))(/ pi 12))
		      )
		     (T
		      (setq ug (/ pi 8))
		      (repeat 20
			(if
			  (or(and (< ug gn)(< gn (+ ug(/ pi 12))) )(eq gn (+ ug(/ pi 12))))
			  (progn
			    (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 p) (cons 11 (polar p (+ ug(/ pi 24)) (/ 6.5 (/ 1000 mg))))))
			    (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (polar p (+ ug(/ pi 24)) (/ 6.5 (/ 1000 mg))))
					   (cons 11 (polar (polar p (+ ug(/ pi 24)) (/ 6.5 (/ 1000 mg)))
							   (+(angle (polar p (+ ug(/ pi 24)) (/ 6.5 (/ 1000 mg))) p) (/ pi 4))
							   (/ 1.6 (/ 1000 mg))))))
			    (entmake (list '(0 . "LINE") '(6 . "Continuous") (cons 10 (polar p (+ ug(/ pi 24)) (/ 6.5 (/ 1000 mg))))
					   (cons 11 (polar (polar p (+ ug(/ pi 24)) (/ 6.5 (/ 1000 mg)))
							   (-(angle (polar p (+ ug(/ pi 24)) (/ 6.5 (/ 1000 mg))) p) (/ pi 4))
							   (/ 1.6 (/ 1000 mg))))))
			    (if (< ug pi)
			      (vla-AddArc model_spece (vlax-3D-point p) (/ 3.5 (/ 1000 mg)) (-(* pi 2)(/ pi 12)) (+(+ ug(/ pi 24))(/ pi 12)))
			      (vla-AddArc model_spece (vlax-3D-point p) (/ 3.5 (/ 1000 mg)) (-(+ ug(/ pi 24))(/ pi 12)) (/ pi 12))
			      )
			    )
			  )
			(setq ug (+ ug(/ pi 12)))
			)
		      )
		     )
		   )
		 )
	       (setq t0 (mapcar '+ t0 (list (distance (list (nth 0 p2) (nth 1 p2)) (list (nth 0 p3) (nth 1 p3))) 0 0)))
	       )
	     (entmake (list '(0 . "TEXT")
			    (cons 10 p)
			    '(72 . 4)
			    (cons 11 (mapcar '- (vlax-curve-getEndPoint 2Dpline_vla) (list (/ (distance p_start (vlax-curve-getEndPoint 2Dpline_vla)) 2) (/ 5 (/ 1000 mg)))))
			    (cons 40 ht)
			    (cons 50 0)
			    (cons 1 (strcat "L="(rtos (distance p_start (vlax-curve-getEndPoint 2Dpline_vla)) 2 1)"м"))
			    (cons 7 styl)))
	     )
	   )
	 )
       )
     ;                               Вставка пересечек
     (if (= q_draw_peres 1)
       (progn
	 (princ"\nВставляю пересечки...")
	 (setq spisokv (extract_coord_polyline pline))
	 (setq t0 t0!)
	 (setq ht (/ 2.5 (/ 1000 mg)))
	 (setq styl (getvar "TEXTSTYLE"))
	 (defun peresechka (pline spisok t0 / spisokv p1 p2 centr nabor n1 n2 n3 t1 t2 2d_pline 2d_spisokv)
	   (setq spisokv (extract_coord_polyline pline))
	   (setq line_type (car spisok))
	   (setq opisanie (cadr spisok))
	   (setq n (1- (length spisokv)))
	   (repeat n
	     (setq p1 (car spisokv))
	     (setq spisokv (cdr spisokv))
	     (setq p2 (car spisokv))
	     (setq nabor (ssget "_X" (list '(0 . "LINE")(cons 6 line_type))))
	     (if (not(eq 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)))
		   (setq centr (inters (list (nth 0 p1) (nth 1 p1)) (list (nth 0 p2) (nth 1 p2))(list (nth 0 t1) (nth 1 t1))(list (nth 0 t2) (nth 1 t2))))
		   (if (not (eq centr nil))
		     (progn
		       (setq point10 (mapcar '+ t0 (list (distance (list (nth 0 p1) (nth 1 p1)) (list (nth 0 centr) (nth 1 centr))) 0 0)))
		       (setq analysis_point_11 (mapcar '+ t0 (list (distance (list (nth 0 p1) (nth 1 p1)) (list (nth 0 centr) (nth 1 centr))) (/(- (+ max_z 10) usl_z)(/ (* mv (/ 1000 mg)) 1000)) 0)))
		       (entmake (list '(0 . "LINE") '(6 . "Continuous")(cons 10 point10)(cons 11 analysis_point_11)))
		       (entmake (list '(0 . "TEXT")  (cons 10 (mapcar '- point10 (list (/ ht 3) (/ ht -3)))) (cons 40 ht) (cons 50 (/ pi 2)) (cons 1 opisanie) (cons 7 styl)))
		       )
		     )
		   (setq n2 (1+ n2))
		   )
		 )
	       )
	     (setq nabor (ssget "_X" (list '(0 . "LWPOLYLINE")(cons 6 line_type))))
	     (if (not(eq nabor nil))
	       (progn
		 (setq n1 (sslength nabor))
		 (setq n2 0)
		 (repeat n1
		   (setq 2d_pline (entget(ssname nabor n2)))
		   (setq 2d_spisokv (extract_coord_lwpolyline 2d_pline))
		   (setq n3 (1- (length 2d_spisokv)))
		   (repeat n3
		     (setq t1 (car 2d_spisokv))
		     (setq 2d_spisokv (cdr 2d_spisokv))
		     (setq t2 (car 2d_spisokv))
		     (setq centr (inters (list (nth 0 p1) (nth 1 p1)) (list (nth 0 p2) (nth 1 p2))(list (nth 0 t1) (nth 1 t1))(list (nth 0 t2) (nth 1 t2))))
		     (if (not (eq centr nil))
		       (progn
			 (setq point10 (mapcar '+ t0 (list (distance (list (nth 0 p1) (nth 1 p1)) (list (nth 0 centr) (nth 1 centr))) 0 0)))
			 (setq analysis_point_11 (mapcar '+ t0 (list (distance (list (nth 0 p1) (nth 1 p1)) (list (nth 0 centr) (nth 1 centr))) (/(- (+ max_z 10)usl_z)(/ (* mv (/ 1000 mg)) 1000)) 0)))
			 (entmake (list '(0 . "LINE") '(6 . "Continuous")(cons 10 point10)(cons 11 analysis_point_11)))
			 (entmake (list '(0 . "TEXT")  (cons 10 (mapcar '- point10 (list (/ ht 3) (/ ht -3)))) (cons 40 ht) (cons 50 (/ pi 2)) (cons 1 opisanie) (cons 7 styl)))
			 )
		       )
		     )
		   (setq n2 (1+ n2))
		   )
		 )
	       )
	     (setq t0 (mapcar '+ t0 (list (distance (list (nth 0 p1) (nth 1 p1)) (list (nth 0 p2) (nth 1 p2))) 0 0)))
	     )
	   ); defun
	(setq spisok  (profile-get-intersection-lines-type-list))
	 (mapcar '(lambda (spis)
		    (peresechka pline spis t0)
		    ) ;_ end of lambda
		 spisok
		 )
	 )
       )
     
          ;                               Вставка подписей точек
     (if (= q_draw_points 1)
       (progn
	 (princ"\nВставляю подписи точек...")
	 (if (= q_chek_v_pr 1)
	   (cond
	     ((or(= q_sel_v_pr 0)(= q_sel_v_pr 1)(= q_sel_v_pr 5))
	      (setq t1_draw_points(mapcar '- t0! (list 0 (/ 10 (/ 1000 mg)))))
	      (setq t2_draw_points t0!)
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      )
	     ((or(= q_sel_v_pr 2)(= q_sel_v_pr 3)(= q_sel_v_pr 4))
	      (setq t1_draw_points(mapcar '- t0! (list 0 (/ 15 (/ 1000 mg)))))
	      (setq t2_draw_points t0!)
	      (setq ht (/ 3.5 (/ 1000 mg)))
	      (setq styl (getvar "TEXTSTYLE"))
	      )
	     )
	   (progn
	     (initget)(setq t1_draw_points(getpoint "\nУкажи нижнюю линию строки подписей точек: "))
	     (initget)(setq t2_draw_points(getpoint "\nУкажи верхнюю линию строки подписей точек: "))
	     (setq ht (/ 3.5 (/ 1000 mg)))
	     (setq styl (getvar "TEXTSTYLE"))
	     )
	   )
	 (setq nabor (ssget "_X" '((0 . "MULTILEADER"))))
	 (if nabor
	   (progn
	     (setq 2D_draw_design_be_2dpoly_trace (draw_2dPoly_be_3dpoly pline))
	     (setq n 0)
	     (repeat (sslength nabor)
	       (setq leaders_list (append leaders_list (list(ssname nabor n))))
	       (setq n (1+ n)))
	     (setq n 0)
	     (while (not(eq n (1-(length leaders_list))))
	       (setq vla-leader (vlax-ename->vla-object(nth n leaders_list)))
	       (if vla-leader
		 (if (> (vla-get-LeaderCount vla-leader) 0)
		   (progn
		     (if (vl-catch-all-error-p(setq ttemp (vl-catch-all-apply 'vla-GetLeaderLineVertices (list vla-leader 0))))
		       (setq ttemp (vl-catch-all-apply 'vla-GetLeaderLineVertices (list vla-leader 1)))
		       )
		     (setq point_list (vlax-safearray->list(vlax-variant-value ttemp)))
		     (setq point_leaders_list (append point_leaders_list (list (list (car point_list)(cadr point_list)))))
		     (setq n (1+ n))
		     )
		   (setq leaders_list(edit-list-del-item-by-number n leaders_list))
		   )
		 )
	       )
	     (setq spisokv (extract_coord_polyline pline))
	     (mapcar '(lambda (x)
			(setq num_vinoska (member (list (car x)(cadr x)) point_leaders_list))
			(if num_vinoska
			  (progn
			    (setq num_vinoska(-(length point_leaders_list)(length num_vinoska)))
			    (setq vla_vinoska (vlax-ename->vla-object (nth num_vinoska leaders_list)))
			    (if (eq (vla-get-ContentBlockName vla_vinoska) "")
			      (setq diskription (vla-get-TextString vla_vinoska))
			      (setq diskription (cadr(extract_302 (entget (nth num_vinoska leaders_list))))))
			    (setq point (list(+(nth 0 t0!)(vlax-curve-getDistAtPoint 2D_draw_design_be_2dpoly_trace (list (car x)(cadr x))))
					     (+(nth 1 t1_draw_points)(/(- (nth 1 t2_draw_points)(nth 1 t1_draw_points))2))
					     ))
			    (entmake (list '(0 . "TEXT")
					   (cons 10 point)
					   '(72 . 4) '(73 . 0)
					   (cons 11 point)
					   (cons 40 ht)
					   (cons 50 0)
					   (cons 1 diskription)
					   (cons 7 styl)))
			    (entmake (list '(0 . "CIRCLE")
					   (cons 10 point)
					   (cons 40 (/(-(nth 1 t2_draw_points)(nth 1 t1_draw_points))2))))
			    )
			  )
			)
		     spisokv
		     )
	     (entdel (vlax-vla-object->ename 2D_draw_design_be_2dpoly_trace))
	     )
	   )
	 )
       )
     
     
     
     )
    )
  (princ)
  )
