(defun C:create_katalog_angle_be_poly_trace ; создает таблицу углов поворота трассы по выбраным полилинии
       (/ 2dpline 2dpline_vla angle-string data-dialog dec file-list g p1 p2 p3 spisokv2d temp-list data-shablon obj-list ssnabor)
  (load_global_variable)
  (setq ssnabor (ssget '((0 . "LWPOLYLINE"))))
  (setq obj-list (convert_ss_to_list ssnabor))
  (if (and obj-list (setq data-dialog (dialog-create_katalog_angle_be_poly_trace)))
    (progn
      (setq data-shablon data-dialog)
      (foreach x obj-list
	(setq data-dialog data-shablon)
	(setq 2Dpline_vla (vlax-ename->vla-object x))
	(setq spisokv2D (extract_coord_lwpolyline (entget x)))
	(setq file-list (append file-list (list (vla-get-Layer 2Dpline_vla))))
	(setq p1 (car spisokv2D))
	(setq file-list (append file-list (list (strcat
						  "Н. тр."
						  "\t"
						  (convert-distance-to-pk-string-d
						    (+(vlax-curve-getDistAtPoint 2Dpline_vla p1)(cadr(assoc"picket-first"data-dialog)))
						    (cadr(assoc"accuracy-picket"data-dialog))T)
						  "\t"
						  (convert-distance-to-pk-string-d
						    (+(vlax-curve-getDistAtPoint 2Dpline_vla p1)(cadr(assoc"picket-first"data-dialog)))
						    (cadr(assoc"accuracy-picket"data-dialog))nil)
						  "\t"
						  "\t"
						  "\t"
						  "\t"
						  (rtos (nth 1 p1) 2 (cadr(assoc"accuracy-coor"data-dialog)))
						  "\t"
						  (rtos (nth 0 p1) 2 (cadr(assoc"accuracy-coor"data-dialog)))))))
	
	(repeat (- (length spisokv2D) 2)
	  (setq p1 (car spisokv2D))
	  (setq p2 (cadr spisokv2D))
	  (setq p3 (caddr spisokv2D))
	  (setq spisokv2D (cdr spisokv2D))
	  (setq g (calculation_angle_be_3points p1 p2 p3))
	  (setq dec (abs(convert-rad-grad (- g pi))))
	  (setq angle-string (convert-dec-to-gms-str-U dec (get-item-by-name-in-list data-dialog "accuracy-angle")))
	  (if (not(< dec (get-item-by-name-in-list data-dialog "min-angle")))
	    (setq file-list (append file-list (list (strcat
						      (if (draw-design-be-poly-trace-chek-number-uk (get-item-by-name-in-list data-dialog "perfix-angle"))
							(progn
							  (setq temp-list (draw-design-be-poly-trace-edit-string+1 (get-item-by-name-in-list data-dialog "perfix-angle")))
							  (setq data-dialog(put-item-by-name-in-list data-dialog "perfix-angle" (nth 0 temp-list)))
							  (nth 1 temp-list)
							  )
							(get-item-by-name-in-list data-dialog "perfix-angle")
							)
						      
						      "\t"
						      (convert-distance-to-pk-string-d
							(+(vlax-curve-getDistAtPoint 2Dpline_vla p2)(cadr(assoc"picket-first"data-dialog)))
							(cadr(assoc"accuracy-picket"data-dialog))T)
						      "\t"
						      (convert-distance-to-pk-string-d
							(+(vlax-curve-getDistAtPoint 2Dpline_vla p2)(cadr(assoc"picket-first"data-dialog)))
							(cadr(assoc"accuracy-picket"data-dialog))nil)
						      "\t"
						      (if (minusp (- g pi))
							(strcat
							  angle-string
							  "\t"
							  "\t")
							(strcat
							  "\t"
							  angle-string
							  "\t"))
						      (rtos (distance p2 p3) 2 (cadr(assoc"accuracy-dist"data-dialog)))
						      "\t"
						      (rtos (nth 1 p2) 2 (cadr(assoc"accuracy-coor"data-dialog)))
						      "\t"
						      (rtos (nth 0 p2) 2 (cadr(assoc"accuracy-coor"data-dialog)))))))
	    )
	  )
	(setq file-list (append file-list (list (strcat
						  "К. тр."
						  "\t"
						  (convert-distance-to-pk-string-d
						    (+(vlax-curve-getDistAtPoint 2Dpline_vla (cadr spisokv2D))(cadr(assoc"picket-first"data-dialog)))
						    (cadr(assoc"accuracy-picket"data-dialog))T)
						  "\t"
						  (convert-distance-to-pk-string-d
						    (+(vlax-curve-getDistAtPoint 2Dpline_vla (cadr spisokv2D))(cadr(assoc"picket-first"data-dialog)))
						    (cadr(assoc"accuracy-picket"data-dialog))nil)
						  "\t"
						  "\t"
						  "\t"
						  "\t"
						  (rtos (nth 1 (cadr spisokv2D)) 2 (cadr(assoc"accuracy-coor"data-dialog)))
						  "\t"
						  (rtos (nth 0 (cadr spisokv2D)) 2 (cadr(assoc"accuracy-coor"data-dialog)))))))
	)
      (file_write_list_to_file
	(strcat
	  (getvar "DWGPREFIX")
	  (substr (getvar "DWGNAME") 1 (-(strlen (getvar "DWGNAME"))4))
	  "_angle_table.txt"
	  )
	file-list
	)
      )
    )
  (princ)
  )

(defun convert-distance-to-pk-string-d (input-distance accuracy flag-1 / )
  ; выражение длинны в виде строки пикета с заданной точностью
  ; 159.189 -> "1+59.19"
  (setq piket (fix(/ input-distance 100.0)))
  (setq metrs (atof(rtos(rem input-distance 100.0)2 accuracy)))
  (if (or (> metrs 100.0) (= metrs 100.0))
    (progn
      (setq piket (1+ piket))
      (setq metrs (- metrs 100.0))
      )
    )
  (if flag-1
    (itoa piket)
    (strcat
      (if (< metrs 10.0)"0" "")
      (rtos metrs 2 accuracy)
      )
    )
  )

(defun get-list-dialog-create_katalog_angle_be_poly_trace ( / list-dialog)
  (setq list-dialog(vlax-ldata-get "geo_tools_dictionary" "dialog-katalog-angle"))
  (if (<(get-item-by-name-in-list list-dialog "version") 1.0)
    (setq list-dialog (list
			(list "version" 1.0)
			
			(list "picket-first" 0)
			(list "accuracy-picket" 2)

			(list "accuracy-angle" 2)
			(list "perfix-angle" "УП ")

			(list "min-angle" 3.0)

			(list "numbers-coor" 0)
			(list "accuracy-coor" 2)
			(list "accuracy-dist" 2)
			)
	  )
    )
  list-dialog
  )

(defun dialog-create_katalog_angle_be_poly_trace(/ list-dialog dcl_id)
  (setq list-dialog(get-list-dialog-create_katalog_angle_be_poly_trace))
  (setq dcl_id (geo-tools-load-dialog "dialog_katalog_angle_trassa"))
  (new_dialog "dialog_katalog_angle_trassa" dcl_id)
  (foreach x (cdr list-dialog)
    (set_tile (car x)
	      (cond
		((="picket-first"(car x))
		 (convert-distance-to-pk-string (cadr x) (cadr (assoc "accuracy-picket" list-dialog)) nil))
		((="min-angle"(car x))
		 (convert-dec-to-gms-str-U (cadr x) (cadr (assoc "accuracy-angle" list-dialog))))
		((="numbers-coor"(car x))
		 (if(>(cadr x)0)
		   (itoa (-(cadr x)2))
		   (itoa (cadr x))))
		((="perfix-angle"(car x))
		 (cadr x)
		 )
		(T
		 (itoa (cadr x)))
		)
	      )
    )
  (action_tile "picket-first"(vl-prin1-to-string'(setq list-dialog(subst (list "picket-first" (convert-pk-string-to-distance $value))(assoc "picket-first" list-dialog) list-dialog))))
  
  (action_tile "accuracy-picket"(vl-prin1-to-string'(setq list-dialog(subst (list "accuracy-picket" (atoi $value))(assoc "accuracy-picket" list-dialog) list-dialog))))

  (action_tile "accuracy-angle"
    (vl-prin1-to-string
      '(progn
	(setq list-dialog(subst (list "accuracy-angle" (atoi $value))(assoc "accuracy-angle" list-dialog) list-dialog))
	(set_tile "min-angle"(convert-dec-to-gms-str-U (cadr (assoc "min-angle" list-dialog)) (cadr (assoc "accuracy-angle" list-dialog))))
	)))
  (action_tile "perfix-angle"(vl-prin1-to-string'(setq list-dialog(subst (list "perfix-angle" $value)(assoc "perfix-angle" list-dialog) list-dialog))))
  
  (action_tile "min-angle"(vl-prin1-to-string'(setq list-dialog(subst (list "min-angle" (convert-str-gms-to-dec-U $value))(assoc "min-angle" list-dialog) list-dialog))))
  
  (action_tile "numbers-coor"; выбор количества символов до запятой
    (vl-prin1-to-string
      '(if
	(> (atoi $value) 0)
	(setq list-dialog(subst (list "numbers-coor" (+ (atoi $value)2))(assoc "numbers-coor" list-dialog) list-dialog))
	(setq list-dialog(subst (list "numbers-coor" 0)(assoc "numbers-coor" list-dialog) list-dialog))
	)
      )
    )
  (action_tile "accuracy-dist"(vl-prin1-to-string'(setq list-dialog(subst (list "accuracy-dist" (atoi $value))(assoc "accuracy-dist" list-dialog) list-dialog))))
  (action_tile "accuracy-coor"(vl-prin1-to-string'(setq list-dialog(subst (list "accuracy-coor" (atoi $value))(assoc "accuracy-coor" list-dialog) list-dialog))))

  (if(eq(start_dialog)0)
    (setq list-dialog nil)
    (vlax-ldata-put "geo_tools_dictionary" "dialog-katalog-angle" list-dialog)
    )
  (unload_dialog dcl_id)
  list-dialog
  )

(defun convert-dec-to-gms-str-U (dec accuracy / mm ss)
  ; переводит десятичные градусы в текстовую строку градусы минуты секунды 180d30'15"
  ;с точностью
  ;0 = 180d
  ;1 = 180d30'
  ;2 = 180d30'15"
  (setq mm (fix(*(- dec(fix dec))60)))
  (setq ss (atoi(rtos(*(-(*(- dec(fix dec))60)(fix(*(- dec(fix dec))60)))60)2 0)))
  (strcat (itoa(fix dec))"°"
	  (if (> accuracy 0)(strcat(if (< mm 10.)"0" "")(itoa mm)"'")"")
	  (if (> accuracy 1)(strcat(if (< ss 10.)"0" "")(itoa ss)"\"")"")
	  )
  )

(defun convert-str-gms-to-dec-U (string / grad minu pos-d pos-m pos-s sek)
  ; переводит текстовую строку градусы минуты секунды 180d30'15" в десятичные градусы
  (setq pos-d (vl-string-position (ascii "°") string))
  (setq pos-m (vl-string-position (ascii "'") string))
  (setq pos-s (vl-string-position (ascii "\"") string))
  (princ (setq grad (if pos-d (atof(substr string 1 pos-d))(atof string))))(terpri)
  (princ (setq minu (if (and pos-d pos-m)(atof(substr string (+ 2 pos-d) (- pos-m pos-d 1)))0.0)))(terpri)
  (princ (setq sek (if (and pos-m pos-s)(atof(substr string (+ 2 pos-m) (- pos-s pos-m 1)))0.0)))(terpri)
  (+(float grad)(/ (+ (float minu)(/ (float sek)60.0))60.0))
  )