(defun C:insert_row_in_table_coordinate (/ n table_obj max-num-row n-max temp-n D NUM NUM_ROW POINT_LIST T1 VINOSKA VLA_VINOSKA pik-point temp-list)
  (vla-StartUndoMark active_document)
  (initget 1)(setq temp-list (entsel "\nВыбери существующую таблицу с координатами: "))
  (setq table_obj (car temp-list))
  (setq pik-point (cadr temp-list))
  (if table_obj
    (progn
      (if (= (cdr (assoc 0 (entget table_obj)))"ACAD_TABLE")
	(if(setq vinoska(car (entsel "\nВыбери выноску: ")))
	  (if (= (cdr (assoc 0 (entget vinoska)))"MULTILEADER")
	    (progn
	      (setq table_obj (vlax-ename->vla-object table_obj))
	      (setq max-num-row (vla-get-rows table_obj))
	      (setq n-max (atoi (vla-GetText table_obj (1- max-num-row) 0)))
	      (if (= :vlax-true(vla-HitTest table_obj (vlax-3d-point (trans pik-point 1 0)) (vlax-3d-point (trans (getvar "VIEWDIR") 1 0)) 'row 'col))
		(if (< row 2)(setq n 1)(setq n (1- row)))
		(progn
		  (initget 1)(setq n (getint (strcat "\nВ какую строку вставлять?(max="(itoa n-max)"): ")))
		  ))
	      (if (or (< (1+ n) max-num-row) (= (1+ n) max-num-row))
		(progn
		  (setq vla_vinoska(vlax-ename->vla-object vinoska))
		  (setq point_list (vlax-safearray->list(vlax-variant-value(vla-GetLeaderLineVertices vla_vinoska 0))))
		  (setq t1 (list (car point_list) (cadr point_list)))
		  (if (eq (vla-get-ContentBlockName vla_vinoska) "")
		    (setq d (vla-get-TextString vla_vinoska))
		    (setq d (strcat"т."(cadr(extract_302 (entget vinoska))))))
		  (vla-InsertRows table_obj (1+ n) 8 1)
		  (setq max-num-row (vla-get-rows table_obj))
;;;		  (setq temp-n (1+ n))
;;;		  (repeat (- max-num-row temp-n)
;;;		    (vla-SetText table_obj temp-n 0(vla-GetText table_obj (1+ temp-n) 0))
;;;		    (setq temp-n (1+ temp-n))
;;;		    )
;;;		  (vla-SetText table_obj (1- temp-n) 0 (itoa (1+ n-max)))
		  (vla-SetText table_obj (1+ n) 0 (if (= n 1)"=1"(strcat "=A"(rtos (1+ n) 2 0)"+1")))
		  (vla-SetText table_obj (+ n 2) 0 (strcat "=A"(rtos (+ n 2) 2 0)"+1"))
		  (vla-SetCellAlignment table_obj (1+ n) 0 acMiddleCenter)
		  (vla-SetText table_obj (1+ n) 1 d)
		  (vla-SetCellAlignment table_obj (1+ n) 1 acMiddleLeft)
		  (vla-SetText table_obj (1+ n) 2 (rtos (nth 1 t1) 2 2))
		  (vla-SetCellAlignment table_obj (1+ n) 2 acMiddleCenter)
		  (vla-SetCellTextHeight table_obj (1+ n) 2 2.8)
		  (vla-SetText table_obj (1+ n) 3 (rtos (nth 0 t1) 2 2))
		  (vla-SetCellAlignment table_obj (1+ n) 3 acMiddleCenter)
		  (vla-SetCellTextHeight table_obj (1+ n) 3 2.8)
		  )
		(princ "\nОшибка! Недопустимый ввод!")
		)
	      )
	    (alert "Выбрана не выноска!")
	    )
	  (princ "\nВыноска не выбрана.")
	  )
	(alert "Выбрана не таблица!")
	)
      )
    (princ "\nТаблица не выбрана.")
    )
  (vla-EndUndoMark active_document)
  (princ)
  )
