	; 命令：mini_wkz_draw
	; 轴网交点布挖孔桩[mini_wkz_draw]
	; 说明：
		; 1、程序可以判断轴网交点，有重复轴线的只插一个桩
		; 2、程序要求的挖孔直径和扩大头直径以后画桩表的时候使用

(apply
	'(lambda( / x )
		(or mai_pile_text
			(not (setq x (mai_panel_search "谜你结构专业设置文件[mini_jiegou_config].lsp")))
			(load x)
		)
	)
	nil
)

(defun c:mini_wkz_draw ( / old_cmd old_osmode
							old_pwidth go_on a_lay x_min x_max
							ss intl wkz_zj wkz_kdzj p1 p2 blkna cc
						)


	(mai_start T)
	(mai_last_com "mini_wkz_draw")
	(mai_get_scale)
	(setq
		old_pwidth (getvar "plinewid")
		old_osmode (getvar "osmode")
		go_on T
		a_lay (list (car maiaxisname) (caddr maiaxisname))
	)
	(setvar "plinewid" 0)
	(setvar "osmode" 0)
	(while go_on
		(princ (strcat "\n当前轴线层为 [ " (mai_lst2str a_lay " , ") " ]."))
		(initget "Z")
		(setq p1 (getpoint "\n[选取轴线层(Z)]输入框选轴线的第一点:<回车退出>"))
		(cond
			(	(not p1) (exit))
			
			(	(= (type p1) 'LIST) (setq go_on nil))
			
			(	(= p1 "Z")
				(princ "\n选择直线line并获取它的旋转角度:<返回>")
				(if (setq p2 (ssget (list (cons 0 "LINE,ARC,CIRCLE,spline,*polyline,ray,xline,ELLIPSE"))))
					(setq a_lay (mai_remove_same (mapcar '(lambda(x)(strcase (mai_dxf 8 x))) (mai_ssget_2_list p2))))
					(princ "\n没有选择到实体.")
				)
			)
		)
	)
	(and
		p1
		(setq p2 (getcorner p1 "\n输入框选轴线的第二点:"))
		(setq intl (ssget "c" p1 p2 (list (cons 0 "LINE,ARC,CIRCLE,lwpolyline") (cons 8 (mai_lst2str a_lay ",")))))
	)
	(or intl (exit))
	(setq
		x_min (mapcar 'min p1 p2)
		x_max (mapcar 'max p1 p2)
		intl (mai_remove_same (apply 'append (mapcar 'cdr (mai_inters_groups (mai_ssget_2_list intl)))))
		intl (vl-remove-if-not '(lambda(x) (vl-every '>= x_max x x_min)) intl)
	)
	(or intl (exit))

	(or mai_wkz_draw (setq mai_wkz_draw (list 800 800)))
	(mapcar 'set '(wkz_zj wkz_kdzj) mai_wkz_draw)
	(setq
		p1 (getint (strcat "\n请输入挖孔桩直径:<" (itoa wkz_zj) ">"))
		wkz_zj (cond (p1) (wkz_zj))
		p1 (getint (strcat "\n请输入挖孔桩扩大头直径:<" (itoa wkz_kdzj) ">"))
		wkz_kdzj (cond (p1) (wkz_kdzj))
		mai_wkz_draw (list wkz_zj wkz_kdzj)
		blkna (strcat "WKZ_" (itoa wkz_zj) "X" (itoa wkz_kdzj))
		mai_wkz_layer (cond (mai_wkz_layer) ((list "WKZ" "2")))
	)
	(or (tblsearch "block" blkna)
		(progn
			(setq p1 (trans (list 0 0 0) 0 1))
			(setvar "clayer" "0")
			(mai_entmake "circle" (list p1 (/ wkz_zj 2)))
			(setq ss (ssadd))
			(ssadd (entlast) ss)
			; (mai_entmake "circle" (list p1 (/ wkz_kdzj 2)))
			; (setq cc (enylast))
			; (mai_loadLtype "xu-xian" "IMINI")
			; (command "_.chprop" cc "" "lt" "xu-xian" "s" mai_scale2 "")
			; (ssadd cc ss)
			(mai_write_block blkna p1 ss T)
		)
	)
	(apply 'mai_create_layer mai_wkz_layer)
	(setq
		cc (* 0.5 wkz_zj)
		cc (list cc cc 0)
	)
	(foreach p1 intl
		(setq ss (ssget "c" (mapcar '- p1 cc) (mapcar '+ p1 cc) (list (cons 0 "insert") (cons 2 "WKZ_*") (cons 8 (car mai_wkz_layer)))))
		(foreach p2 (mai_ssget_2_list ss)
			(if (mai_equal (trans (mai_dxf 10 p2) 0 1) p1)
				(entdel p2)
			)
		)
		(mai_insert_entmake blkna p1 1 1 1 0)
	)
	(mai_end)
)
