(defun C:profile_draw_pk_and_up ( /
				 block-obj block-profile-obj buffer-zone comm curent-profile elivation
				 height-text horizontal-scale plan-point profil-point profile-mode
				 reference-level scale-coefficient start-point trace-2dpline vertical-scale
				 curent-text-style data-dialog coor-trace profile-parameters angle-string
				 dec g insert-point p1 p2 p3 temp-list current-picket dist-tressa flag picket-first)
  ; 
  (setq profile-mode (vlax-ldata-get "geo_tools_dictionary" "profile-mode"))
  (if(if (not profile-mode)(profile-seleckt-curent-mode)T)
    (if (=(vlax-ldata-get "geo_tools_dictionary" "profile-mode")1)
      (progn
	(setq curent-profile(vlax-ldata-get "geo_tools_dictionary" "curent-profile"))
	(if curent-profile
	  (if (vlax-erased-p (cdr curent-profile))
	    (alert "Ошибка! Текущий профиль был удален.\nВыбрать другой текущий профиль можно с помощью команды \"Выбрать текущий профиль\"")
	    (progn
	      (princ (strcat"\nТекущий профиль: "(car curent-profile)))
(vla-StartUndoMark active_document)
		  (setq block-profile-obj (cdr curent-profile))
		  
		  (setq block-obj (cdr(assoc "block"(vlax-ldata-get block-profile-obj"obj-list"))))
		  (setq vertical-scale (vlax-ldata-get block-profile-obj"vertical-scale"))
		  (setq horizontal-scale (vlax-ldata-get block-profile-obj"horizontal-scale"))
		  (setq scale-coefficient (/ 1.0 (/ 1000.0 horizontal-scale)))
		  (setq height-text (*(atof(nth 9 (vlax-ldata-get block-profile-obj"profile-parameters")))scale-coefficient))
		  (setq reference-level (vlax-ldata-get block-profile-obj"reference-level"))
		  (setq buffer-zone(*(atof(nth 3 (vlax-ldata-get block-profile-obj"profile-parameters")))scale-coefficient))
		  (setq start-point(mapcar'+ (vlax-safearray->list(vlax-variant-value(vla-get-InsertionPoint block-profile-obj)))(list buffer-zone 0)))
		  (setq trace-2Dpline (trace-create-2Dpline-by-block-profile block-profile-obj))
		  (setq coor-trace(vlax-ldata-get block-profile-obj"coor-trace"))
	      (setq profile-parameters(vlax-ldata-get block-profile-obj"profile-parameters"))
	      (setq curent-text-style (nth 1 profile-parameters))
	      (if(or(eq curent-text-style "***Текущий***")(not(member curent-text-style(get-text-style-list))))
		(setq curent-text-style(getvar "TEXTSTYLE")))
	      
     (setq data-dialog (dialog-profile-draw-pk-and-up))
     
     (if (eq (cadr (assoc "draw-mleader" data-dialog)) 1)
       (progn
	 (setq p1 (car coor-trace))
	 (repeat (- (length coor-trace) 2)
	   (setq p1 (car coor-trace))
	   (setq p2 (cadr coor-trace))
	   (setq p3 (caddr coor-trace))
	   (setq coor-trace (cdr coor-trace))
	   (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 dec (get-item-by-name-in-list data-dialog "accuracy-angle")))
	   (if (not(< dec (get-item-by-name-in-list data-dialog "min-angle")))
	     (progn
	       (setq plan-point (vlax-curve-getDistAtPoint trace-2Dpline (vlax-curve-getClosestPointTo trace-2Dpline (list (car p2)(cadr p2)0))))
	       (setq insert-point (list(+(nth 0 start-point)plan-point)(nth 1 start-point)))
	       (draw-text-vla-by-list-property(list
						(cons "spece" model_spece)
						(cons "TextString" (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")
								       )
								     angle-string))
						(cons "InsertionPoint" (list (nth 0 insert-point) (+(nth 1 start-point)(/ height-text 2))))
						(cons "Height" height-text)
						(cons "Rotation" (/ pi 2))
						(cons "Alignment" 12)
						(cons "StyleName" curent-text-style)
						))
	       )
	     )
	   )
	 
	 )
       )
     (if (eq (get-item-by-name-in-list data-dialog "draw-picket") 1)
       (progn
	 (setq picket-first (vlax-ldata-get block-profile-obj"picket-first"))
	 (setq dist-tressa (vla-get-Length trace-2Dpline))
	 (setq current-picket(+(*(fix(/ picket-first 100.00))100.00)100.00))
	 (setq flag (if (>(- current-picket picket-first)dist-tressa)T nil))
	 (while (not flag)
	   (setq insert-point (list(+(nth 0 start-point)(- current-picket picket-first))(nth 1 start-point)))
	   (draw-text-vla-by-list-property(list
					    (cons "spece" model_spece)
					    (cons "TextString" (strcat "ПК" (convert-distance-to-pk-string current-picket (get-item-by-name-in-list data-dialog "accuracy-picket") nil)))
					    (cons "InsertionPoint" (list (nth 0 insert-point) (+(nth 1 start-point)(/ height-text 2))))
					    (cons "Height" height-text)
					    (cons "Rotation" (/ pi 2))
					    (cons "Alignment" 12)
					    (cons "StyleName" curent-text-style)
					    ))
	   
	   (setq current-picket(+ current-picket 100.00))
	   (setq flag (if (>(- current-picket picket-first)dist-tressa)T))
	   )
	 (if (=(get-item-by-name-in-list data-dialog "draw-start-end-picket")1)
	   (progn
	     (setq insert-point (list(nth 0 start-point)(nth 1 start-point)))
	     (draw-text-vla-by-list-property(list
					      (cons "spece" model_spece)
					      (cons "TextString" (strcat "ПК" (convert-distance-to-pk-string picket-first (get-item-by-name-in-list data-dialog "accuracy-picket") nil)))
					      (cons "InsertionPoint" (list (nth 0 insert-point) (+(nth 1 start-point)(/ height-text 2))))
					      (cons "Height" height-text)
					      (cons "Rotation" (/ pi 2))
					      (cons "Alignment" 12)
					      (cons "StyleName" curent-text-style)
					      ))
	     

	     (setq insert-point (list(+(nth 0 start-point)dist-tressa)(nth 1 start-point)))
	     (draw-text-vla-by-list-property(list
					      (cons "spece" model_spece)
					      (cons "TextString" (strcat "ПК" (convert-distance-to-pk-string (+ picket-first dist-tressa) (get-item-by-name-in-list data-dialog "accuracy-picket") nil)))
					      (cons "InsertionPoint" (list (nth 0 insert-point) (+(nth 1 start-point)(/ height-text 2))))
					      (cons "Height" height-text)
					      (cons "Rotation" (/ pi 2))
					      (cons "Alignment" 12)
					      (cons "StyleName" curent-text-style)
					      ))

	     ))
	 )
       )
	      

(vla-delete trace-2Dpline)
     (vla-EndUndoMark active_document)

	      
	      
	      )
	    )
	  (alert "Ошибка! Текущий профиль не определен.\nВыбрать текущий профиль можно с помощью команды \"Выбрать текущий профиль\"")
	  )
	)
      (alert "Данная команда не работает в режиме \"старый профиль\"!")
      )
    )
  (princ)
  )


(defun dialog-profile-draw-pk-and-up( / list-dialog dcl_id)
(setq list-dialog(get-list-dialog-profile-draw-pk-and-up))
  (setq dcl_id (geo-tools-load-dialog "d_profile_draw_pk_and_up"))
  (new_dialog "d_profile_draw_pk_and_up" dcl_id)
  (mode-tile-in-dialog-profile-draw-pk-and-up list-dialog)
  (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 (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)
		 )
		((or(="version"(car x))(="width-poly"(car x)))
		 (rtos(cadr x)2 2)
		 )
		(T
		 (itoa (cadr x)))
		)
	      )
    )
;;;  (if flag-3D
;;;    (mode_tile "del-bak-2poly" 0)
;;;    (mode_tile "del-bak-2poly" 1))
  (action_tile "draw-picket"
    (vl-prin1-to-string
      '(progn
	(setq list-dialog(subst (list "draw-picket" (atoi $value))(assoc "draw-picket" list-dialog) list-dialog))
	(mode-tile-in-dialog-profile-draw-pk-and-up 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 "draw-start-end-picket"(vl-prin1-to-string'(setq list-dialog(subst (list "draw-start-end-picket" (atoi $value))(assoc "draw-start-end-picket" list-dialog) list-dialog))))
  
  
  (action_tile "draw-mleader"
    (vl-prin1-to-string
      '(progn
	(setq list-dialog(subst (list "draw-mleader" (atoi $value))(assoc "draw-mleader" list-dialog) list-dialog))
	(mode-tile-in-dialog-profile-draw-pk-and-up 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 (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 "accuracy-picket-angle"(vl-prin1-to-string'(setq list-dialog(subst (list "accuracy-picket-angle" (atoi $value))(assoc "accuracy-picket-angle" list-dialog) list-dialog))))
;;;  (action_tile "draw-start-end-picket-angle"(vl-prin1-to-string'(setq list-dialog(subst (list "draw-start-end-picket-angle" (atoi $value))(assoc "draw-start-end-picket-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 $value))(assoc "min-angle" list-dialog) list-dialog))))
  
;;;  (action_tile "draw-coor"
;;;    (vl-prin1-to-string
;;;      '(progn
;;;	(setq list-dialog(subst (list "draw-coor" (atoi $value))(assoc "draw-coor" list-dialog) list-dialog))
;;;	(mode-tile-in-dialog-profile-draw-pk-and-up 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-coor"(vl-prin1-to-string'(setq list-dialog(subst (list "accuracy-coor" (atoi $value))(assoc "accuracy-coor" list-dialog) list-dialog))))
  
;;;  (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 "width-poly"(vl-prin1-to-string'(setq list-dialog(subst (list "width-poly" (atof $value))(assoc "width-poly" list-dialog) list-dialog))))
;;;  (action_tile "del-bak-2poly"(vl-prin1-to-string'(setq list-dialog(subst (list "del-bak-2poly" (atoi $value))(assoc "del-bak-2poly" list-dialog) list-dialog))))
  
  (if(eq(start_dialog)0)
    (setq list-dialog nil)
    (vlax-ldata-put "geo_tools_dictionary" "dialog-profile-draw-pk-and-up" list-dialog)
    )
  (unload_dialog dcl_id)
  list-dialog
  )

(defun mode-tile-in-dialog-profile-draw-pk-and-up (list-dialog / )
  (if (=(cadr (assoc "draw-picket" list-dialog))0)
    (foreach x (list "accuracy-picket" "draw-start-end-picket" )(mode_tile x 1))
    (foreach x (list "accuracy-picket" "draw-start-end-picket" )(mode_tile x 0))
    )
  (if
    (=(cadr (assoc "draw-mleader" list-dialog))0)
    (foreach x (list "accuracy-angle" "perfix-angle"
;;;		     "accuracy-picket-angle"
;;;		     "draw-start-end-picket-angle"
		     "min-angle"
;;;		     "draw-coor" "numbers-coor" "accuracy-coor"
		     )(mode_tile x 1))
    (progn
      (foreach x (list "accuracy-angle" "perfix-angle"
;;;		       "accuracy-picket-angle"
;;;		       "draw-start-end-picket-angle"
		       "min-angle"
;;;		     "draw-coor" "numbers-coor" "accuracy-coor"
		       )(mode_tile x 0))
;;;      (if
;;;	(=(cadr (assoc "draw-coor" list-dialog))0)
;;;	(foreach x (list "numbers-coor" "accuracy-coor" )(mode_tile x 1))
;;;	(foreach x (list "numbers-coor" "accuracy-coor" )(mode_tile x 0))
;;;	)
      )
    )
  )


(defun get-list-dialog-profile-draw-pk-and-up ( / list-dialog)
  (setq list-dialog(vlax-ldata-get "geo_tools_dictionary" "dialog-profile-draw-pk-and-up"))
  (if (<(get-item-by-name-in-list list-dialog "version") 1.0)
    (setq list-dialog (list
			(list "version" 1.0)
			
			(list "draw-picket" 1)
			(list "accuracy-picket" 2)
			(list "draw-start-end-picket" 1)
			
			(list "draw-mleader" 1)
			(list "accuracy-angle" 2)
			(list "perfix-angle" "УП ")
			(list "accuracy-picket-angle" 2)
;;;			(list "draw-start-end-picket-angle" 0)
			(list "min-angle" 3.0)
			
;;;			(list "draw-coor" 1)
;;;			(list "numbers-coor" 0)
;;;			(list "accuracy-coor" 2)
			
;;;			(list "picket-first" 0.0)
;;;			(list "width-poly" 0.3)
;;;			(list "del-bak-2poly" 1)
			)
	  )
    )
  list-dialog
  )