(defun draw_blok_ramka (block_name auto_insert stamp insetrt_smal_shtamp model-list / flag_shtamp block n  block_name_list width height temp
			w_stamp h_stamp points_vsp1 points_vsp2 points_list points_ramka Line x)
  
  (load_global_variable)
  (setq block_name_ (strcat (substr block_name 1 (+ 1(vl-string-position (ascii " ")block_name 0 T)))
			    " ("
			    (substr block_name(+ 2(vl-string-position (ascii " ")block_name 0 T)))
			    ")"));"ГОСТ A0x2 1189x1682"
  (if (and(eq (getvar "CTAB") "Model")(eq model-list nil))
    (progn
      (setq flag_shtamp stamp)
      (cond
	((eq flag_shtamp "Нет")
	 (if (eq (substr block_name 1 3) "ISO")
	   (setq block_name(strcat (substr block_name 1 3) "н"(substr block_name 4 (-(strlen block_name)3))))
	   (setq block_name(strcat (substr block_name 1 4) "н"(substr block_name 5 (-(strlen block_name)4)))))
	 )
	((eq flag_shtamp "ГОСТ")
	 (setq w_stamp 185
	       h_stamp 55)
	 )
	((eq flag_shtamp "Большой")
	 (setq w_stamp 130
	       h_stamp 130)
	 (if (eq (substr block_name 1 3) "ISO")
	   (setq block_name(strcat (substr block_name 1 3) "б"(substr block_name 4 (-(strlen block_name)3))))
	   (setq block_name(strcat (substr block_name 1 4) "б"(substr block_name 5 (-(strlen block_name)4)))))
	 )
	((eq flag_shtamp "Маленький")
	 (setq w_stamp 130
	       h_stamp 15)
	 (if (eq (substr block_name 1 3) "ISO")
	   (setq block_name(strcat (substr block_name 1 3) "м"(substr block_name 4 (-(strlen block_name)3))))
	   (setq block_name(strcat (substr block_name 1 4) "м"(substr block_name 5 (-(strlen block_name)4))))))
	)
      (setq block_name (strcat "_" block_name))
      )
    )

(if(and(or(/= (getvar "CTAB") "Model")(eq model-list T))(eq insetrt_smal_shtamp T))
  (if (eq (substr block_name 1 3) "ISO")
	   (setq block_name(strcat (substr block_name 1 3) "и"(substr block_name 4 (-(strlen block_name)3))))
	   (setq block_name(strcat (substr block_name 1 4) "и"(substr block_name 5 (-(strlen block_name)4))))))
  
  (if
    (tblobjname "block" block_name)
    (if (= auto_insert "Нет")
      (progn
	(princ "\nУкажи точку вставки: ")
	(setvar "CMDECHO" 0)
	(command "_insert" block_name "_S" (/ 1 (getvar "CANNOSCALEVALUE")) pause
		 (if (and(eq (getvar "CTAB") "Model")(eq model-list nil)) pause 0.0))
	(setvar "CMDECHO" 1))
      )
    (progn
      (setq block_name_list (analisis_block_name_for_width_height block_name))
      (setq width (car block_name_list))
      (setq height (cadr block_name_list))
      (setq block (vla-Add (vla-get-Blocks active_document) (vlax-3D-point '(0 0 0)) block_name))
      (if
	(and(eq (getvar "CTAB") "Model")(eq model-list nil))
	(progn
	  (setq points_vsp1
		 (append(list
			  (list 25 10 0)
			  (list 25 (- height 10) 0)
			  (list (- width 10) (- height 10) 0))
			(if (eq flag_shtamp "Нет")
			  (list(list (- width 10) 10 0))
			  (progn(list(list (- width 10) (+ h_stamp 10) 0)
				     (list (- width (+ w_stamp 10)) (+ h_stamp 10) 0)
				     (list (- width (+ w_stamp 10)) 10 0)
				     )))))
	  (setq points_vsp2
		 (append(list
			  (list 20 5 0)
			  (list 20 (- height 5) 0)
			  (list (- width 5) (- height 5) 0))
			(if (eq flag_shtamp "Нет")
			  (list(list (- width 5) 5 0))
			  (progn(list(list (- width 5) (+ h_stamp 5) 0)
				     (list (- width (+ w_stamp 5)) (+ h_stamp 5) 0)
				     (list (- width (+ w_stamp 5)) 5 0)
				     )))))
	  (draw_2dpoly_vla block points_vsp2 40)
	  (draw_2dpoly_vla block points_vsp1 0)
	  )
	(progn
	  (setq points_list(list (list 0 0 0)
				 (list 0 height 0)
				 (list width height 0)
				 (list width 0 0)))
	  (setq points_ramka(list (list 20 5 0)
				  (list 20 (- height 5) 0)
				  (list (- width 5) (- height 5) 0)
				  (list (- width 5) 5 0)))
	  (draw_2dpoly_vla block points_list 0)
	  (draw_2dpoly_vla block points_ramka 40)
	  
	  (draw-text-vla-by-list-property
	    (list
	      (cons "spece" block)
	      (cons "TextString" block_name_)
	      (cons "InsertionPoint" (list (- width 5) 2.5 0))
	      (cons "Height" 2.5)
	      (cons "Rotation" 0)
	      (cons "Color" 0)
	      (cons "Alignment" 11)
	      ))
	  
	  (if insetrt_smal_shtamp
	    (progn
	      (mapcar '(lambda (x)(setq Line(vla-AddLine block (vlax-3D-point(nth 0 x))(vlax-3D-point(nth 1 x))))
			 (vla-put-Linetype Line "Continuous")
			 (vla-put-Lineweight Line 40)
			 (vla-put-Layer Line "0")
			 (vla-put-color Line 0)
			 )
		      (list(list'(12.5 90 0) '(12.5 5 0))
			   (list'(7.5 90 0) '(7.5 5 0))
			   (list'(7.5 90 0) '(20 90 0))
			   (list'(7.5 65 0) '(20 65 0))
			   (list'(7.5 30 0) '(20 30 0))
			   (list'(7.5 5 0) '(20 5 0))
			   ))
	      (mapcar '(lambda (x)(setq text (vla-AddText block (nth 0 x) (vlax-3D-point (nth 1 x)) 2))
			 (vla-put-Linetype text "Continuous")
			 (vla-put-Layer text "0")
			 (vla-put-color text 0)
			 (vla-put-Rotation text (/ pi 2))
			 (vla-put-StyleName text (getvar "TEXTSTYLE"))
			 )
		      (list(list "Инв. N подл." '(11.0 6.8 0.0))
			   (list "Подп. и дата" '(11.0 36.0 0.0))
			   (list "Взам. инв. N" '(11.0 66.5 0.0))
			   ))
	      ))
	  )
	)
      (if (= auto_insert "Нет")
	(progn
	  (princ "\nУкажи точку вставки: ")
	  (setvar "CMDECHO" 0)
	  (command "_insert" block_name "_S" (/ 1 (getvar "CANNOSCALEVALUE")) pause
		   (if (and(eq (getvar "CTAB") "Model")(eq model-list nil)) pause 0.0))
	  (setvar "CMDECHO" 1))
	)
      )
    )
  (if
    (or(and(eq (getvar "CTAB") "Model")(eq model-list T)(/= shtamp "Нет"))(and(/= (getvar "CTAB") "Model")(/= shtamp "Нет")))
    (progn
      (setq insert_poit (cdr(assoc 10(entget(entlast)))))
      (draw_blok_shtamp shtamp "Да")
      (setq block_name_list (analisis_block_name_for_width_height block_name))
      (setq width (car block_name_list))
      (setq height (cadr block_name_list))
      (entmake (list '(0 . "INSERT") '(2 . "Штамп")
		     (cons 10 (mapcar '+ insert_poit
				      (list(-(* width(/ 1 (getvar "CANNOSCALEVALUE")))
					     (* 5.0(/ 1 (getvar "CANNOSCALEVALUE"))))
					   (* 5.0(/ 1 (getvar "CANNOSCALEVALUE")))
					   0.0)))
		     (cons 41 (/ 1 (getvar "CANNOSCALEVALUE")))
		     (cons 42 (/ 1 (getvar "CANNOSCALEVALUE")))
		     '(43 . 1.0)))
      (command "_explode" (entlast))
      (if(tblobjname "block" "Штамп")(command "_-purge" "Б" "Штамп" "Н"))
      )
    )
  block_name
  )