(or mai_cehui_gcd_blk
	(mai_load_files (mai_panel_search "谜你测绘功能设置文件.lsp"))
)


;-------------------------------------
(defun Action_all_00j_Keys ( key value / tmp_dir bb zdsj num lj high style str sj pt chk ) ;全部控件的点击动作触发
	(cond
		(	(= key "accept")  ;;;{确认按钮}
			(setq bb
				(list
					(Dcl:List-Getv "PopupZD")
					(Dcl:List-Getv "PopupYS")
					; (Dcl:List-Getv "PopupGD")
					(get_tile "ListWB")
					(get_tile  "EditLJ")
					(Dcl:List-Getv "PopupGS")
				)
			)
			; (mai_set_style (car mai_cehui_style) T)
			(if (= (getvar "userr1") 0.0)
				(setvar "userr1" 500.0)
			)
			; (setvar "pdmode" 35)
			; (setvar "PDSIZE" 0.3)
			(apply 'mai_create_layer mai_cehui_gcd_dianhao)
			(apply 'mai_create_layer mai_cehui_gcd_bianma)
			(apply 'mai_create_layer mai_cehui_gcd_blk)
			;获取文件与文件数据
			(setq zdsj nil)
			(foreach num (mai_str2lst2 (nth 2 bb) " ")
				(setq
					lj (strcat (nth 3 bb) (nth (atoi num) slds))
					zdsj (cons lj zdsj)
				)
			)
			;根据格式获取文件数据
			(setq
				sjlst
					(if (= (strcase (vl-filename-extension lj)) ".DAT")  ;文件循环获取数据
						(mapcar
							'(lambda(a)(mai_str2lst2 a ","))
							(apply 'append (mapcar '(lambda(lj)(mai_read_file lj nil nil T)) zdsj))
						)
					)
					;;数据展点
					;(list "点号+编码+高程" "点号+编码" "编码+高程" "点号+高程" "点号" "编码" "高程")
				high (* mai_scale2 (cadr mai_cehui_style))
				style (cadr bb)
				str
					(if (= (nth 4 bb) "平面X,平面Y")
						"(mapcar '(lambda(x)(atof(nth x sj)))(list 3 2 4))"
						"(mapcar '(lambda(x)(atof(nth x sj)))(list 2 3 4))"
					)
			)
			(foreach sj sjlst
				(setq pt (eval (read str)))
				;;构造点
				;构造点号
				(and
					(setq chk (wcmatch (car bb) "*点号*"))
					(not (mai_not_str (car sj)))
					(entmakeX
						(list
							'(0 . "TEXT")
							(cons 1 (car sj))
							(cons 7 style)
							(cons 8 (car mai_cehui_gcd_dianhao))
							(cons 10 (mapcar '+ (list 0 (* 0.5 high) 0) pt))
							(cons 40 high)
						)
					)
				)
				;构造编码
				(and
					(wcmatch (car bb) "*编码*")
					(not (mai_not_str (cadr sj)))
					(entmakeX
						(list
							'(0 . "TEXT")
							(cons 1 (cadr sj))
							(cons 7 style)
							(cons 8 (car mai_cehui_gcd_bianma))
							(cons 10 (if chk (mapcar '+ (list 0 (* 1.5 high) 0) pt) pt))
							(cons 40 high)
						)
					)
				)
				;构造高程
				(if (wcmatch (car bb) "*高程*")
					(gxl_cs:gcd pt (caddr pt) mai_scale2 2 (car mai_cehui_gcd_blk))
					(entmakeX (list '(0 . "POINT") (cons 10 pt) (cons 8 (car mai_cehui_gcd_dianhao))))
				)
			)
			(vla-ZoomExtents (vlax-get-acad-object))
			;("点号+编码+高程" "仿宋" "1.0" "0 1 2" "C:\\Users\\Administrator\\Desktop\\松山湖环湖路")
			(Get_all_00j_Data)
			(done_dialog 1)
		)

		(	(= key "GetFolar") ;;;{"选择根目录"} (按钮)
			(setq tmp_dir (mai_Getdir "选择目录" zd_path))
			(if tmp_dir
				(progn
					(setq zd_path tmp_dir)
					(set_tile "EditLJ" zd_path)
					(Dcl:List-Set "ListWB" (setq slds (mai_dos_dir zd_path "*.dat")) nil)
				)
			)
		)
	)
)
;-------------------------------------
(defun Get_all_00j_Data ( / key );临时生成Dcl文件 返回文件名
	(foreach key keys
		(set (read (strcat key "_bak")) (get_tile key));每个控件都赋给一个变量 用于下次开启初始化
	)
)
;-------------------------------------
(defun Write_Dcl_all_00j( / Dcl_File file str )
	(setq Dcl_File (vl-filename-mktemp nil nil ".Dcl")
		  file (open Dcl_File "w")
	)
	(foreach str
		(list
			"CassZBZD:dialog{ label = \"坐标展点 [迷你修改版版 ]\" ;"
			"    :column {"
			"        :row { :button { fixed_width = true ; key = \"GetFolar\" ; label = \"选择根目录\" ; width = 5 ; }"
			"               :edit_box { key = \"EditLJ\" ; width = 60 ; }"
			"        }"
			"        :button { is_enabled = false ; key = \"jinzhi\" ; label = \"展点格式：点号,代码,平面坐标X,平面坐标Y,地面高程\" ; }"
			"        :row {"
			"            :column { fixed_width = true ; width = 50 ;"
			"                :popup_list { key = \"PopupZD\" ; label = \"展点功能\" ; }"
			"                :popup_list { key = \"PopupGS\" ; label = \"展点格式\" ; }"
			"                :popup_list { key = \"PopupYS\" ; label = \"字体样式\" ; }"
			; "                :popup_list { key = \"PopupGD\" ; label = \"字体高度\" ; }"
			"            }"
			"            :column { fixed_width = true ; width = 40 ;"
			"                :list_box { key = \"ListWB\" ; multiple_select = true ;}"
			"            }"
			"        }"
			"    }"
			"    ok_cancel;"
			"}"
		 )
		(write-line str file)
	)
	(close file)
	Dcl_File
)

;;说明:下拉菜单数据填充
;;参数:key:控件
;;参数:lst:表数据
;;参数:item:设置初始值
;;返回:
(defun Dcl:List-Set ( key lst item / change data sym sym_fun update)
	(or (listp lst) (setq lst nil))
	(setq sym_fun (read (strcat key ":list_box_fun")))
	(or (eval sym_fun) (set sym_fun 'vl-princ-to-string))
	(setq sym (read (strcat key ":list_box_data")))
	(set sym lst)
	(start_list key)
	(mapcar 'add_list (mapcar (eval sym_fun) lst))
	(end_list)
	(setq data (eval (read (strcat key ":list_box_data"))))
	(if (= (type item) 'INT)
		(set_tile key (itoa (if (member item data) (vl-position item data) item)))
		(if (member item data) ;字符时
			(set_tile key (itoa (vl-position item data)))
		)
	)
)
;;;取当前项
(defun Dcl:List-Getv ( key / veal index data ) ;index a data
	(or (= (setq index (get_tile key)) "")
		(setq
			data (eval (read (strcat key ":list_box_data")))
			veal (nth (atoi index) data)
		)
	)
	veal
)

;;于2017年7月26日创作
;;于2017年8月18日增加获取文档路径下的展点文件
;;感谢  wkq004  提供插入高程点函数
;;作者：范建威
;坐标展点[fjw_ZBZD].lsp
;-------------------------------------
(defun C:fjw_ZBZD ( / old_cmd dcl_id dcl_file dialog_return keys key keys zd_path slds sjlst zd_path )
	(mini_start nil)
	(mai_last_com "fjw_ZBZD")
	(mai_get_scale)
	(mai_set_style (car mai_cehui_style) nil)
	(setq dcl_id (load_dialog (setq Dcl_File (Write_Dcl_all_00j))));对话框加载
	(vl-file-delete Dcl_File) ;加载后删除DCL文件
	(setq Dialog_Return 2)
	(while (> Dialog_Return 1) ;循环控制对话框是否结束
		(new_dialog "CassZBZD" dcl_id);建立窗体
		;--->--->---对话框初始化--->--->---
		(setq keys '("GetFolar" "EditLJ" "jinzhi" "PopupZD" "PopupYS" "PopupGD" "PopupDYS" "PopupGS" "accept" "cancel"))
		;->->-下拉列表初始化->->-
		(Dcl:List-Set "PopupZD" (list "点号+编码+高程" "点号+编码" "点号+高程" "编码+高程" "点号" "编码" "高程") 0)
		(Dcl:List-Set "PopupGS" (list "平面X,平面Y" "平面Y,平面X") 0)
		(Dcl:List-Set "PopupYS" (mai_tblsearch "style") (car mai_cehui_style))
		; (Dcl:List-Set "PopupGD" (list "0.3" "0.5" "0.8" "1.0" "1.3" "1.5" "1.8" "2.0" "2.5" "3.0" "3.5") nil)
		(or zd_path (setq zd_path (getvar "dwgprefix")))
		(or (= zd_path "")
			(progn
				(Dcl:List-Set "ListWB" (setq slds (mai_dos_dir zd_path "*.dat")) nil)
				(set_tile "EditLJ" zd_path)
			)
		)
		
		
		;-<-<-下拉列表初始化完成-<-<-
		(foreach key keys ;全部控件的初始化
			(if (eval (read (strcat key "_bak"))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
			(action_tile key "(Action_all_00j_Keys $key $value)");点击动作 $reason
		)
		;---<---<---对话框初始化完成---<---<---
		(setq Dialog_Return (start_dialog));开启对话框(用户可见)
	)
	(unload_dialog dcl_id);退出时卸载对话框
	(mai_end);防止函数回显
)
