(defun C:draw_table_coord_region ( / 2dpline_vla nn num_row p p1 p3 paper_spece pline spisok ss t0 table_obj x dir-angle)
  ; выводит геоданные участка по замкнутой полилинии

  (geo_tools-help "draw_table_coord_region")
  (load_global_variable)
  (initget)(setq pline (car (entsel "\nВыбери замкнутую полилинию границы участка: ")))
  (cond
    ((eq pline nil)
     (alert "Ничего не выбрано!"))
    ((not(eq (cdr(assoc 0 (entget pline))) "LWPOLYLINE"))
     (alert "Выбрана не 2D полилиния!"))
    ((eq (cdr(assoc 0 (entget pline))) "LWPOLYLINE")
     (vla-StartUndoMark active_document)
     (create-table-style);создает стиль таблиц каталога координат
     (setq 2Dpline_vla (vlax-ename->vla-object pline))
     (setq spisok (extract_coord_lwpolyline (entget pline)))
     
     (if(setq t0 (getpoint "\nУкажи точку вставки таблицы координат <Выход>: "))
       (progn
	 (setq table_obj (vla-AddTable model_spece (vlax-3D-point t0) 2 5 12 20))
	 (vla-put-StyleName table_obj "Координаты")
	 (vla-SetColumnWidth table_obj 0 8)
	 
	 (vla-SetText table_obj 0 0 "Геоданные")
	 (vla-SetCellTextHeight table_obj 0 0 4.0)
	 (vla-SetCellAlignment table_obj 0 0 acMiddleCenter)
	 
	 (vla-SetText table_obj 1 0 "N")
	 (vla-SetCellTextHeight table_obj 1 0 2.8)
	 (vla-SetCellAlignment table_obj 1 0 acMiddleCenter)
	 
	 (vla-SetText table_obj 1 1 "X")
	 (vla-SetCellAlignment table_obj 1 1 acMiddleCenter)
	 (vla-SetCellTextHeight table_obj 1 1 2.8)
	 
	 (vla-SetText table_obj 1 2 "Y")
	 (vla-SetCellAlignment table_obj 1 2 acMiddleCenter)
	 (vla-SetCellTextHeight table_obj 1 2 2.8)
	 
	 (vla-SetText table_obj 1 3 "Длина")
	 (vla-SetCellAlignment table_obj 1 3 acMiddleCenter)
	 (vla-SetCellTextHeight table_obj 1 3 2.8)
	 
	 (vla-SetText table_obj 1 4 "Дир.углы")
	 (vla-SetCellAlignment table_obj 1 4 acMiddleCenter)
	 (vla-SetCellTextHeight table_obj 1 4 2.8)
	 
	 (vla-SetColumnWidth table_obj 4 25.0)
	 (vla-put-horzcellmargin table_obj 0.5)
	 (vla-put-vertcellmargin table_obj 0.5)
	 (vla-SetRowHeight table_obj 1 12.0)
;;;	 (setq ss (ssadd))
	 (setq nn 1)
	 (mapcar '(lambda (x); обработка списка точек полилинии
		    (cond ; подписываем точки на границе
		      ((eq (vl-position x spisok) 0) ; первая точка в списке
		       (setq p1(nth (1-(length spisok)) spisok))
		       (setq p3(nth(1+(vl-position x spisok))spisok))
		       )
		      ((eq (vl-position x spisok) (1-(length spisok))); последняя точка в списке
		       (setq p1(nth(1-(vl-position x spisok))spisok))
		       (setq p3(nth 0 spisok))
		       )
		      (T ; все осальные точки списка
		       (setq p1(nth(1-(vl-position x spisok))spisok))
		       (setq p3(nth(1+(vl-position x spisok))spisok))
		       )
		      )
		    (cond; положение текста подписи точки
		      ((> (calculation_angle_be_3points p1 x p3) (calculation_angle_be_3points p3 x p1))
		       (setq p (polar x (+(angle x p3) (/(calculation_angle_be_3points p1 x p3)2)) (/ 5 (getvar "CANNOSCALEVALUE")))))
		      ((< (calculation_angle_be_3points p1 x p3) (calculation_angle_be_3points p3 x p1))
		       (setq p (polar x (+(angle x p1) (/(calculation_angle_be_3points p3 x p1)2)) (/ 5 (getvar "CANNOSCALEVALUE")))))
		      ((= (calculation_angle_be_3points p1 x p3) (calculation_angle_be_3points p3 x p1))
		       (setq p (polar x (+(angle x p3) (/ pi 2)) (/ 5 (getvar "CANNOSCALEVALUE"))))))
		    
		    (draw-text-vla-by-list-property
			 (list
			   (cons "spece" (if (eq (getvar "CTAB")"Model")model_spece paper_spece))
			   (cons "TextString" (strcat "н"(rtos nn 2 0)))
			   (cons "InsertionPoint" p)
			   (cons "Height" (/ 3 (getvar "CANNOSCALEVALUE")))
			   (cons "Rotation" 0)
			   (cons "Alignment" 4)
			   ))

		    (draw-insertblock-vla-by-list-property
		      (list(cons "spece" (if (eq (getvar "CTAB")"Model")model_spece paper_spece))
			   (cons "InsertionPoint" x)
			   (cons "EffectiveName" "Пикет")
			   (cons "XScaleFactor" 2.0)
			   (cons "YScaleFactor" 2.0)
			   (cons "ZScaleFactor" 2.0)
			   (cons "Rotation" 0.0)
			   ))
		    
;;;		    (ssadd (entlast) ss)
;;;		    (setvar "CMDECHO" 0)
;;;		    
;;;		    (vl-cmdf "-objectscale" ss "" "_Add" (getvar "CANNOSCALE") "")
;;;		    (command)
;;;		    (setvar "CMDECHO" 1)
;;;		    
;;;		    (ssdel (ssname ss 0) ss)
		    
		    (setq num_row (vla-get-rows table_obj)); количество строк в таблице
		    ; номер и координаты
		    (vla-InsertRows table_obj (1+ num_row) 4 2)
		    (vla-SetRowHeight table_obj (1+ num_row) 5.2)
		    (vla-mergeCells table_obj num_row (1+ num_row) 0 0)
		    (vla-mergeCells table_obj num_row (1+ num_row) 1 1)
		    (vla-mergeCells table_obj num_row (1+ num_row) 2 2)
		    
		    (vla-SetText table_obj num_row 0 (strcat "н"(rtos nn 2 0)))
		    (vla-SetCellAlignment table_obj num_row 0 acMiddleCenter)
		    (vla-SetCellTextHeight table_obj num_row 0 2.8)
		    
		    (vla-SetText table_obj num_row 1 (rtos (nth 1 x) 2 2))
		    (vla-SetCellAlignment table_obj num_row 1 acMiddleCenter)
		    (vla-SetCellTextHeight table_obj num_row 1 2.8)
		    
		    (vla-SetText table_obj num_row 2 (rtos (nth 0 x) 2 2))
		    (vla-SetCellAlignment table_obj num_row 2 acMiddleCenter)
		    (vla-SetCellTextHeight table_obj num_row 2 2.8)
		    
		    (vla-SetRowHeight table_obj (1+ num_row) 5.0)
		    (vla-SetRowHeight table_obj num_row 5.0)
		    
		    ;Длины и дир.углы
		    (if (not(eq (vl-position x spisok) 0)); первая точка не обрабатывается
		      (progn
			(setq p1(nth(1-(vl-position x spisok))spisok))
			(if(> nn (length spisok));последняя точка
			  (progn

			    )
			  (progn
			    ; Длины линий
			    (vla-mergeCells table_obj (1- num_row) num_row 3 3)
			    (vla-SetText table_obj (1- num_row) 3 (rtos(distance x p1)2 2))
			    (vla-SetCellAlignment table_obj (1- num_row) 3 acMiddleCenter)
			    (vla-SetCellTextHeight table_obj (1- num_row) 3 2.8)
			    ; Дир.углы
			    (if (or (>(setq dir-angle(+(/ pi 2)(-(* pi 2)(angle p1 x))))(* pi 2))(= dir-angle (* pi 2)))
			      (setq dir-angle (- dir-angle(* pi 2))))
			    (vla-mergeCells table_obj (1- num_row) num_row 4 4)
			    (vla-SetText table_obj (1- num_row) 4 (vl-string-subst"%%d" "d"(convert-dec-to-gms-str (convert-rad-grad dir-angle) 2)0))
			    (vla-SetCellAlignment table_obj (1- num_row) 4 acMiddleCenter)
			    (vla-SetCellTextHeight table_obj (1- num_row) 4 2.8)
			    )
			  )
			)
		      )
		    (vla-SetCellGridVisibility table_obj (1+ num_row) 0 acBottomMask :vlax-false)
		    (vla-SetCellGridVisibility table_obj (1+ num_row) 1 acBottomMask :vlax-false)
		    (vla-SetCellGridVisibility table_obj (1+ num_row) 2 acBottomMask :vlax-false)
		    (vla-SetCellGridVisibility table_obj num_row 3 acBottomMask :vlax-false)
		    (vla-SetCellGridVisibility table_obj num_row 4 acBottomMask :vlax-false)
		    (setq nn (1+ nn))
		    )
		 spisok)
	 (vla-InsertRows table_obj (+ num_row 2) 4 1)
	 (vla-SetRowHeight table_obj (+ num_row 2) 5.2)
	 
	 (vla-mergeCells table_obj (1+ num_row) (+ num_row 2) 3 3)
	 (vla-SetText table_obj (1+ num_row) 3 (rtos(distance (nth (1-(length spisok)) spisok) (nth 0 spisok))2 2))
	 (vla-SetCellAlignment table_obj (1+ num_row) 3 acMiddleCenter)
	 (vla-SetCellTextHeight table_obj (1+ num_row) 3 2.8)
	 
	 (vla-mergeCells table_obj (1+ num_row) (+ num_row 2) 4 4)
	 (vla-SetText table_obj (1+ num_row) 4 (vl-string-subst"%%d" "d"(convert-dec-to-gms-str (convert-rad-grad(angle (nth (1-(length spisok)) spisok) (nth 0 spisok))) 2)0))
	 (vla-SetCellAlignment table_obj (1+ num_row) 4 acMiddleCenter)
	 (vla-SetCellTextHeight table_obj (1+ num_row) 4 2.8)
	 
	 (setq num_row (vla-get-rows table_obj))
	 (vla-InsertRows table_obj (1+ num_row) 8 1)
	 (vla-mergeCells table_obj num_row num_row 0 2)
	 (vla-mergeCells table_obj num_row num_row 3 4)
	 (vla-SetText table_obj num_row 0 (strcat "Периметр "(rtos (vla-get-Length 2Dpline_vla) 2 0) " м"))
	 (vla-SetCellTextHeight table_obj num_row 0 2.4)
	 (vla-SetCellAlignment table_obj num_row 0 acMiddleCenter)
	 (vla-SetText table_obj num_row 3 (strcat "Общая площадь "(rtos (vla-get-Area 2Dpline_vla) 2 0) " кв.м."))
	 (vla-SetCellTextHeight table_obj num_row 3 2.4)
	 (vla-SetRowHeight table_obj num_row 8.0)
	 (vla-SetCellAlignment table_obj num_row 3 acMiddleCenter)
	 (vla-SetCellGridVisibility table_obj num_row 2 acRightMask :vlax-false)
	 (vla-ScaleEntity table_obj (vlax-3D-point t0) (/ 1 (getvar "CANNOSCALEVALUE")))
	 )
       )
     (vla-EndUndoMark active_document)
     )
    )
  (princ)
  )