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


(defun c:fjw_zbzd ( / old_cmd main_setting cfgname mai_sym_list old_pwidth
						dat_file gcd_dianhao gcd_bianma gcd_blk_lay gcd_blk dat_type pt_type txt_style txt_hight read_data read_data_2
						gcd_units gcd_scale gcd_tin gcd_tin_style gcd_dgx gcd_dgx_hight gcd_style gcd_dgx_style
					)
(defun main_setting ( / stop mm nn tmp )
	(if (and (not (mai_not_str dat_file))
			(setq dat_file (findfile dat_file))
		)
		(setq
			read_data (mai_read_file dat_file nil nil T)
			read_data_2 (mapcar '(lambda(x)(mai_str_replace x "，" ",")) read_data)
		)
		(setq dat_file "" read_data nil read_data_2 nil)
	)
	(while (not stop)
		(setq
			mm nil
			mm (mai_dcl_model1
					(list (list "-15" ))
					0
					"【坐标展点】"
					(list 1 1 60 0.01 -15 nil nil)
					(list
						(list "" 1 40)
						(list
							(if (mai_not_str dat_file)
								"展点文件:<无>"
								(strcat "展点文件:<" (vl-filename-base dat_file) ".dat>")
							)
							"get_done" T
						)
						(list
							(if (mai_not_str dat_file)
								"文件路径：<无>"
								(strcat "文件路径：<" (vl-filename-directory dat_file) ">")
							)
							"text" T
						)
						(list "点号图层:" "get_layer" gcd_dianhao)
						(list "文字图层:" "get_layer" gcd_bianma)
						(list "文字字型:" "get_style" txt_style)
						(list "文字字高:" (list "get_dist" 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5) txt_hight)
						(list "高程块层:" "get_layer" gcd_blk_lay)
						(list "高程点块:" "get_block" gcd_blk)
						(list "数据展点:" (list "点号+编码+高程" "点号+编码" "编码+高程" "点号+高程" "点号" "编码" "高程") dat_type)
						(list "坐标顺序:" (list "radio" "平面X,平面Y" "平面Y,平面X") pt_type)
						(list "制图单位:" (list "radio" "1=1米" "1=1毫米") gcd_units)
						(list "制图比例 1:" (list "get_dist" 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1250 1500 1750 2000 2500 3000 4000 5000) gcd_scale)
						(list "三角网层:" "get_layer" gcd_tin)
						(list "三角网实体类型:" (list "radio" "3DFACE" "3DPOLWLINE") gcd_tin_style)
						(list "等高线层:" "get_layer" gcd_dgx)
						(list "等高线高差:" (list "get_dist" 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5) gcd_dgx_hight)
						(list "曲线拟合等高线" "toggle" gcd_dgx_style)
						(list "生成选项:" (list "radio" "高程" "高程+三角网" "高程+三角网+等高线") gcd_style)
					)
					(list (list "展点数据：<点号,代码,平面坐标X,平面坐标Y,地面高程>" 60 25 nil nil nil nil) read_data_2 0)
					nil
				)
			nn (cadddr mm)
			mm (cddadr mm)
		)
		(if mm
			(progn
				(mapcar '(lambda(x y)(set (car x) y)) mai_sym_list (cons dat_file mm))
				(mai_write_config cfgname mai_sym_list 'mai_zbzd_op)
				(cond
					(	(= 1 nn)
						(if (setq tmp (mai_getfile "选择展点文件" mai_mini_path "dat"))
							(setq
								dat_file tmp
								read_data (mai_read_file dat_file nil nil T)
								read_data_2 (mapcar '(lambda(x)(mai_str_replace x " ，" ",")) read_data)
							)
						)
					)
					(	(setq stop T)
						(do_it)
					)
				)
			)
			(setq stop T)
		)
	)
	(princ)
)

(defun do_it ( /  sj pt chk pts )
	(setq
		mai_scale gcd_scale
		mai_draw_units (if (= gcd_units "1=1米") 0.001 1)
		gcd_dgx_hight (* gcd_dgx_hight (if (= gcd_units "1=1米") 1 1000))
	)
	(mai_load_dim_style (>= mai_scale maidimsite))
	(mai_get_scale)
	(apply 'mai_create_layer gcd_dianhao)
	(apply 'mai_create_layer gcd_bianma)
	(apply 'mai_create_layer gcd_blk_lay)
	;根据格式获取文件数据
	(setq
		read_data (mapcar '(lambda(a)(mai_str2lst2 a ",")) read_data)
			;(list "点号+编码+高程" "点号+编码" "编码+高程" "点号+高程" "点号" "编码" "高程")
		txt_hight (* txt_hight mai_scale2)
	)
	(princ "\n正在展点，耐心等候......")
	(foreach sj read_data
		(setq pt (cddr sj))
		(if (eq pt_type "平面X,平面Y")
			(setq pt (list (cadr pt) (car pt) (caddr pt)))
		)
		(setq
			chk (if (= gcd_units "1=1米") 1 1000)
			pt (mapcar 'atof pt)
			pt (list (* chk (car pt)) (* chk (cadr pt)) (* chk (caddr pt)))
			pts (cons pt pts)
		)
		;;构造点
		;构造点号
		(and
			(setq chk (wcmatch dat_type "*点号*"))
			(not (mai_not_str (car sj)))
			(entmakeX
				(list
					(cons 0 "TEXT")
					(cons 1 (car sj))
					(cons 7 txt_style)
					(cons 8 (car gcd_dianhao))
					(cons 10 (mapcar '+ (list 0 (* 0.5 txt_hight) 0) pt))
					(cons 40 txt_hight)
				)
			)
		)
		;构造编码
		(and
			(not (mai_not_str (cadr sj)))
			(wcmatch dat_type "*编码*")
			(entmakeX
				(list
					(cons 0 "TEXT")
					(cons 1 (cadr sj))
					(cons 7 txt_style)
					(cons 8 (car gcd_bianma))
					(cons 10 (if chk (mapcar '+ (list 0 (* 1.5 txt_hight) 0) pt) pt))
					(cons 40 txt_hight)
				)
			)
		)
		;构造高程
		(if (wcmatch dat_type "*高程*")
			(gxl_cs:gcd pt (caddr pt) mai_scale2 2 gcd_blk)
			(entmakeX (list '(0 . "POINT") (cons 10 pt) (cons 8 (car gcd_blk_lay))))
		)
	)
	(vla-ZoomExtents (vlax-get-acad-object))
	(setq chk (entlast))
	(or (= gcd_style "高程")
		(progn
			(princ "\n三角网数据处理中......")
			(apply 'mai_create_layer gcd_tin)
			(mapcar '(lambda (x) (mai_a_triangle (mapcar '(lambda(y)(nth y pts)) x) nil (= gcd_tin_style "3DFACE"))) (mai_points_triangle pts))
		)
	)
	(if (= gcd_style "高程+三角网+等高线")
		(progn
			(princ "\n等高线数据处理中......")
			(apply 'mai_create_layer gcd_dgx)
			(setq
				pts (mapcar
						'(lambda (x)(setq x (entget x)) (mai_remove_same (list (mai_dxf 10 x)(mai_dxf 11 x)(mai_dxf 12 x)(mai_dxf 13 x))))
						(mai_ssget_2_list (mai_newset chk))
					)
				chk (entlast)
			)
			(mai_faces_elev pts gcd_dgx_hight)
			(and
				(= gcd_dgx_style "1")
				(setq sj (mai_ssget_2_list (mai_newset chk)))
				(foreach pts sj (command "_.pedit" pts "F" ""))
			)
		)
	)
)




	(mini_start nil)
	(mai_last_com "fjw_zbzd")
	(setq
		cfgname (mai_fix_dir1 (strcat mai_mini_path "Plus_lib\\迷你收录插件\\测绘\\Mini_zbzd.cfg"))
		mai_sym_list
			(list
				(list 'dat_file			"")
				(list 'gcd_dianhao		mai_cehui_gcd_dianhao)
				(list 'gcd_bianma		mai_cehui_gcd_bianma)
				(list 'txt_style 		(car mai_cehui_style))
				(list 'txt_hight 		(cadr mai_cehui_style))
				(list 'gcd_blk_lay		mai_cehui_gcd_blk)
				(list 'gcd_blk			mai_cehui_gc_blkname)
				(list 'dat_type			"点号+编码+高程")
				(list 'pt_type			"平面X,平面Y")
				(list 'gcd_units 		"1=1米")
				(list 'gcd_scale 		500)
				(list 'gcd_tin			mai_cehui_tin)         ;三角网所在图层及颜色
				(list 'gcd_tin_style	"3DFACE")        		 ;三角网所在图层及颜色
				(list 'gcd_dgx 			mai_cehui_dgx)         ;等高线所在图层及颜色
				(list 'gcd_dgx_hight 	1)        			 ;等高线所在图层及颜色
				(list 'gcd_dgx_style 	"1")        			 ;等高线所在图层及颜色
				(list 'gcd_style 		"高程+三角网+等高线")
			)
		old_pwidth (getvar "plinewid")
	)
	(mai_read_config cfgname mai_sym_list 'mai_zbzd_op)
	(setvar "plinewid" 0)
	(main_setting)
	(mai_end)
)
