(defun C:insert_rastr_by_numenklature_mix_500-msk-saratov (/ file-name list_files insert-point ln nn obj convert-sys-property height width file-name)
  ; создание .map файла растра (МСК-Саратов М1:500) по номенклатуре
  
  (defun create-map-file (file_ point-1 krest-dist face convert-sys-property / file-name point-2 point-3 point-4 map-list point-1-bl point-2-bl point-3-bl point-4-bl)
    (setq file-name (strcat (vl-filename-base file_) (vl-filename-extension file_)))
    (setq point-2 (mapcar '+ point-1 (list krest-dist 0.0 )))
    (setq point-3 (mapcar '+ point-1 (list krest-dist (* krest-dist -1.0))))
    (setq point-4 (mapcar '+ point-1 (list 0.0 (* krest-dist -1.0))))
    (setq point-1-bl(convert-xy-to-bl-wgs-84-by-property convert-sys-property point-1))
    (setq point-2-bl(convert-xy-to-bl-wgs-84-by-property convert-sys-property point-2))
    (setq point-3-bl(convert-xy-to-bl-wgs-84-by-property convert-sys-property point-3))
    (setq point-4-bl(convert-xy-to-bl-wgs-84-by-property convert-sys-property point-4))
    (setq map-list(create-map-list file-name
		    (nth 0 point-1-bl)(nth 1 point-1-bl)
		    (nth 0 point-2-bl)(nth 1 point-2-bl)
		    (nth 0 point-3-bl)(nth 1 point-3-bl)
		    (nth 0 point-4-bl)(nth 1 point-4-bl)
		    (/ krest-dist face) (rtos face 2 0)))
    (file_write_list_to_file (strcat (vl-filename-directory file_) "\\" (vl-filename-base file_) ".map") map-list)
    )
  (defun create-map-list (file--name b1 l1 b2 l2 b3 l3 b4 l4 scale face)
    (list
      "OziExplorer Map Data File Version 2.2"
      file--name
      file--name
      "1 ,Map Code,"
      "WGS 84,,   0.0000,   0.0000,WGS 84"
      "Reserved 1"
      "Reserved 2"
      "Magnetic Variation,,,E"
      "Map Projection,Mercator,PolyCal,No,AutoCalOnly,No,BSBUseWPX,No"
      (strcat"Point01,xy,    0, 0,in, deg, "(convert-dec-to-dd_mm-print_to_png_area b1)",N, "(convert-dec-to-dd_mm-print_to_png_area l1)",E, grid,   ,           ,           ,N")
      (strcat"Point02,xy,    "face", 0,in, deg, "(convert-dec-to-dd_mm-print_to_png_area b2)",N, "(convert-dec-to-dd_mm-print_to_png_area l2)",E, grid,   ,           ,           ,N")
      (strcat"Point03,xy,    "face", "face",in, deg, "(convert-dec-to-dd_mm-print_to_png_area b3)",N, "(convert-dec-to-dd_mm-print_to_png_area l3)",E, grid,   ,           ,           ,N")
      (strcat"Point04,xy,    0, "face",in, deg, "(convert-dec-to-dd_mm-print_to_png_area b4)",N, "(convert-dec-to-dd_mm-print_to_png_area l4)",E, grid,   ,           ,           ,N")
      "Point05,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point06,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point07,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point08,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point09,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point10,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point11,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point12,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point13,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point14,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point15,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point16,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point17,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point18,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point19,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point20,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point21,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point22,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point23,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point24,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point25,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point26,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point27,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point28,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point29,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Point30,xy,     ,     ,in, deg,    ,        ,N,    ,        ,W, grid,   ,           ,           ,N"
      "Projection Setup,,,,,,,,,,"
      "Map Feature = MF ; Map Comment = MC     These follow if they exist"
      "Track File = TF      These follow if they exist"
      "Moving Map Parameters = MM?    These follow if they exist"
      "MM0,Yes"
      "MMPNUM,4"
      "MMPXY,1,0,0"
      (strcat"MMPXY,2,"face",0")
      (strcat"MMPXY,3,"face","face)
      (strcat"MMPXY,4,0,"face)
      (strcat"MMPLL,1, "(rtos b1 2 6)", "(rtos l1 2 6))
      (strcat"MMPLL,2, "(rtos b2 2 6)", "(rtos l2 2 6))
      (strcat"MMPLL,3, "(rtos b3 2 6)", "(rtos l3 2 6))
      (strcat"MMPLL,4, "(rtos b4 2 6)", "(rtos l4 2 6))
      (strcat"MM1B,"(rtos scale 2 6))
      "MOP,Map Open Position,0,0"
      (strcat"IWH,Map Image Width/Height,"face","face)
      )
    )
  
  (defun create-tfw-file (input-point file_ scale_ /)
    (file_write_list_to_file (strcat (vl-filename-directory file_) "\\" (vl-filename-base file_) ".tfw")
      (list
	(rtos scale_ 2 16)
	"0.0000000000000"
	"0.0000000000000"
	(rtos (* -1 scale_) 2 16)
	(rtos (nth 0 input-point)2 16)
	(rtos (nth 1 input-point)2 16)
	))
    
    )
  
  (setq convert-sys-property(dialog-print_to_png_area))
  
  (setq list_files (file_find_be_extension "d:\\500\\3 rename" "tif"))
  (setq ln (itoa (length list_files)))
  (setq nn 0)
  (foreach file list_files
    (setq file-name (vl-filename-base file))
    (setq insert-point (get-point-by_numenklature500-msk-saratov file-name))
    (setq messege (strcat(itoa nn)"/"ln))
    (grtext -1 messege)
    (name-file-to-messege messege)
    (command "-image" "_attach" file insert-point "1" "0")
    (setq obj (vlax-ename->vla-object (entlast)))
    (vla-put-ImageHeight obj 250.0)
    (vla-put-ImageWidth obj 250.0)
    (setq Height(vla-get-Height obj))
    (setq Width(vla-get-Width obj))
;;;    (princ file)
    (create-map-file
      file
      (mapcar '+ insert-point (list 0.0 250.0))
      250
      (min Height Width)
      convert-sys-property)
    (create-tfw-file (mapcar '+ insert-point (list 0.0 250.0)) file (/ 250.0 (min Height Width)))
    (setq nn (1+ nn))
    )
  (grtext -1 "")
  (delete-name-file-to-messege)
;;;  (command "_qsave")
  (princ)
  )