(defun C:gps_vedovisti ( / hard-point-list list_hard_points list_surv_points b n nn
			surv-point-list hard_point list-str-itog list-str-kovalent list-str-points
			dist-hard-surv dir-angle angle-line delta-H error-H error-dist)
  (load_global_variable)
  (if
    C3D_active_document
    (progn
      (princ "\nВыбери жесткие cogo-точки.")
      (if (not(vl-catch-all-error-p(setq list_hard_points (vl-catch-all-apply 'vlax-invoke (list C3D_active_document 'SelectPoints)))))
	(progn
	  (foreach hard_point list_hard_points
	    (setq C3D_point (vlax-invoke C3D_points 'find hard_point))
	    (setq hard-point-list
		   (append hard-point-list
			   (list
			     (list
			       (list "name"(vlax-get C3D_point 'name))
			       (list "number"(itoa(vlax-get C3D_point 'number)))
			       (list "N"(vlax-get C3D_point 'northing))
			       (list "E"(vlax-get C3D_point 'easting))
			       (list "Z"(vlax-get C3D_point 'elevation))
			       (list "description"(vlax-get C3D_point 'RawDescription))
			       )))))
	  (princ "\nВыбери определяемые cogo-точки.")
	  (if (not(vl-catch-all-error-p(setq list_surv_points (vl-catch-all-apply 'vlax-invoke (list C3D_active_document 'SelectPoints)))))
	    (progn
	      (foreach surv_point list_surv_points
		(setq C3D_point (vlax-invoke C3D_points 'find surv_point))
		(setq surv-point-list
		       (append surv-point-list
			       (list
				 (list
				   (list "name"(vlax-get C3D_point 'name))
				   (list "number"(itoa(vlax-get C3D_point 'number)))
				   (list "N"(vlax-get C3D_point 'northing))
				   (list "E"(vlax-get C3D_point 'easting))
				   (list "Z"(vlax-get C3D_point 'elevation))
				   (list "description"(vlax-get C3D_point 'RawDescription))
				   )))))
	      (setq n 0)
	      (setq b 1)
	      (foreach hard_point hard-point-list
		(setq nn n)
		(repeat (-(length hard-point-list)1 nn)
		  (setq nn (1+ nn))
		  (draw-line-vla-by-list-property
		    (list
		      (cons "spece" (if (eq (getvar "CTAB")"Model")model_spece paper_spece))
		      (cons "StartPoint" (list (cadr(assoc "E"hard_point)) (cadr(assoc "N"hard_point)) 0.0))
		      (cons "EndPoint" (list (cadr(assoc "E"(nth nn hard-point-list))) (cadr(assoc "N"(nth nn hard-point-list))) 0.0))
		      (cons "Color" 1)
		      (cons "Lineweight" 40)
		      ))
		  (setq list-str-kovalent
			 (append list-str-kovalent
				 (list
				   (strcat
				     "B"(itoa b)"\t"(cadr(assoc "description" hard_point))"\t"(cadr(assoc "description" (nth nn hard-point-list)))
				     "\tАз.\t"
				     (convert-rad-to-str-grad
				       (calculation_angle_be_3points
					 (list (cadr(assoc "E"hard_point))(+(cadr(assoc "N"hard_point))100.0)0.0)
					 (list (cadr(assoc "E"hard_point))(cadr(assoc "N"hard_point))0.0)
					 (list (cadr(assoc "E"(nth nn hard-point-list)))(cadr(assoc "N"(nth nn hard-point-list)))0.0)))"\t0°00'00.0000\"\t1:0\t1:0\t\n"
				     "\t\t\tDВыс.\t"(rtos (-(cadr(assoc "Z" hard_point))(cadr(assoc "Z" (nth nn hard-point-list))))2 3) "м\t0.000м\n"
				     "\t\t\tРасст.\t"(rtos (distance (list (cadr(assoc "E"hard_point))(cadr(assoc "N"hard_point))0.0)
								     (list (cadr(assoc "E"(nth nn hard-point-list)))(cadr(assoc "N"(nth nn hard-point-list)))0.0))2 3) "м\t0.000м"
				     ))))
		  (setq list-str-itog
			 (append list-str-itog
				 (list
				   (strcat
				     "B"(itoa b)
				     "\t"(cadr(assoc "description" hard_point))
				     "\t"(cadr(assoc "description" (nth nn hard-point-list)))
				     "\t"(rtos (distance (list (cadr(assoc "E"hard_point))(cadr(assoc "N"hard_point))0.0)
							 (list (cadr(assoc "E"(nth nn hard-point-list)))(cadr(assoc "N"(nth nn hard-point-list)))0.0))2 3) "м"
				     ))))
		  (setq b (1+ b))
		  )
		(foreach surv_point surv-point-list
		  (setq dist-hard-surv (distance (list (cadr(assoc "E"hard_point))(cadr(assoc "N"hard_point))0.0)
						 (list (cadr(assoc "E"surv_point))(cadr(assoc "N"surv_point))0.0)))
		  (setq dir-angle (calculation_angle_be_3points
				    (list (cadr(assoc "E"hard_point))(+(cadr(assoc "N"hard_point))100.0)0.0)
				    (list (cadr(assoc "E"hard_point))(cadr(assoc "N"hard_point))0.0)
				    (list (cadr(assoc "E"surv_point))(cadr(assoc "N"surv_point))0.0)))
		  (setq angle-line (angle(list (cadr(assoc "E"hard_point))(cadr(assoc "N"hard_point))0.0) (list (cadr(assoc "E"surv_point))(cadr(assoc "N"surv_point))0.0)))
		  (setq delta-H (-(cadr(assoc "Z" hard_point))(cadr(assoc "Z" surv_point))))
		  (setq error-H (+ 0.005 (* (/ dist-hard-surv 1000000.0) 1.05)))
		  (setq error-dist (+ 0.003 (* (/ dist-hard-surv 1000000.0) 1.2)))
		  (draw-line-vla-by-list-property
		    (list
		      (cons "spece" (if (eq (getvar "CTAB")"Model")model_spece paper_spece))
		      (cons "StartPoint" (list (cadr(assoc "E"hard_point)) (cadr(assoc "N"hard_point)) 0.0))
		      (cons "EndPoint" (list (cadr(assoc "E"surv_point)) (cadr(assoc "N"surv_point)) 0.0))
		      ))
		  (setq list-str-kovalent
			 (append list-str-kovalent
				 (list
				   (strcat
				     "B"(itoa b)"\t"(cadr(assoc "description" hard_point))"\t"(cadr(assoc "description" surv_point))
				     "\tАз.\t"(convert-rad-to-str-grad dir-angle)"\t0°00'0"(rtos (/ dir-angle 2) 2 4)"\"\t1:"(rtos (/ dist-hard-surv error-dist) 2 0)"\t1:"(rtos (/ dist-hard-surv (/(+ error-H error-dist)2)) 2 0)"\t\n"
				     "\t\t\tDВыс.\t"(rtos delta-H 2 3) "м\t"(rtos error-H 2 3)"м\n"
				     "\t\t\tРасст.\t"(rtos dist-hard-surv 2 3) "м\t"(rtos error-dist 2 3)"м"
				     ))))
		  (setq list-str-itog
			 (append list-str-itog
				 (list
				   (strcat
				     "B"(itoa b)
				     "\t"(cadr(assoc "description" hard_point))
				     "\t"(cadr(assoc "description" surv_point))
				     "\t"(rtos dist-hard-surv 2 3) "м"
				     ))))
		  (setq b (1+ b))
		  )
		(setq n (1+ n))
		)
	      (foreach x (append hard-point-list surv-point-list)
		(setq list-str-points
		       (append list-str-points
			       (list
				 (strcat
				   (cadr(assoc "description" x))
				   "\t"(rtos(cadr(assoc "N" x))2 3)
				   "\t"(rtos(get-rng-number 0.009 nil)2 3)
				   "\t"(rtos(cadr(assoc "E" x))2 3)
				   "\t"(rtos(get-rng-number 0.009 nil)2 3)
				   "\t"(rtos(cadr(assoc "Z" x))2 3)
				   "\t"(rtos(get-rng-number 0.009 nil)2 3)
				   "\t\t"
				   ))))
		)
	      (file_write_list_to_file
		(strcat
		  (getvar "DWGPREFIX")
		  (substr (getvar "DWGNAME") 1 (-(strlen (getvar "DWGNAME"))4))
		  "_gps.txt"
		  )
		(append list-str-points list-str-kovalent list-str-itog)
		)
	      )
	    
	    )
	  
	  )
	)
      )
    (alert "Выполнение комманды предполагает ее запуск в AutoCAD Civil 3D!\nТекущий AutoCAD им не является или представляет собой не поддерживаемую(временно?) версию.")
    )
  (princ)
  )