(defun c:Fs_dimHole (/	   c1	 c2    cir   d1	   d2	 enp   ss
		     txt   deep	 htp   ps    ps1   ps2	 str   dimhole
		     sc
		    )
  (setq	enp (fsxm-entsel
	      "\n选择要标注的孔之大圆："
	      '((0 . "circle,arc,dimension"))
	    )
  )
  (or enp (fsxm-silenceexit))
  ;;====
  (defun dimhole (d1		d2	      htp
		  ps		deep	      /
		  dimhole:act:accept	      dimhole:dcl:show
		  dimhole:act:type	      showtp
		  drwline	dimhole
		 )
    (defun drwline (key lst)
      (start_image key)
      (mapcar (function
		(lambda (a) (apply 'vector_image a))
	      )
	      lst
      )
      (end_image)
    )
    (defun showtp (htp / l)
      (fsxm-loadsld "type" 0)
      (if (= htp "v")
	(setq l	'(
		  (20 7 21 7 2)
		  (20 16 20 7 2)
		  (4 16 20 16 2)
		  (3 16 4 16 2)
		  (21 16 3 16 2)
		  (3 7 4 7 2)
		  (3 16 3 7 2)
		  (4 16 3 16 2)
		 )
	)
	(setq l	'(
		  (3 9 3 8 2)
		  (11 17 3 9 2)
		  (11 17 11 17 2)
		  (11 17 20 8 2)
		  (11 17 11 17 2)
		  (20 9 11 17 2)
		 )
	)
      )
      (drwline "type" l)
    )
    (defun dimhole:act:type ()
      (if (= htp "v")
	(setq htp "w")
	(setq htp "v")
      )
      (showtp htp)
    )
    (defun dimhole:dcl:show ()
      (showtp htp)
      (set_tile "d1" d1)
      (set_tile "d2" d2)
      (set_tile "deep" deep)
      (set_tile "ps" ps)
    )
    (defun dimhole:act:accept (/ d1 deep ps)
      (setq d1 (get_tile "d1"))
      (setq deep (get_tile "deep"))
      (if (/= deep "")
	(setq deep (strcat "深" deep))
      )
      (if (/= (setq ps (get_tile "ps")) "")
	(setq ps (strcat ps "-"))
      )
      (return (strcat "{\\fAMGDT;"
		      htp
		      "}%%C"
		      d1
		      deep
		      "\\P"
		      ps
		      "%%C"
		      (get_tile "d2")
	      )
      )
    )
    (setq ldcl '("hole"
		 (:DIALOG
		  (INITIAL_FOCUS "deep")
		  (LABEL "沉头孔标注1.0 By Fsxm")
		  "spacer;"
		  (:ROW
		   "spacer;"
		   (:BOXED_COLUMN
		    (:ROW
		     (ALIGNMENT CENTERED)
		     (FIXED_WIDTH TRUE)
		     (:SWATCH (COLOR BLACK) (KEY "type"))
		     (:TEXT (LABEL "Φ"))
		     (:EDIT (KEY "d1"))
		     (:TEXT (LABEL "深"))
		     (:EDIT (KEY "deep"))
		    )
		    (:IMAGE (COLOR BLUE) (HEIGHT 0.2))
		    (:ROW
		     (ALIGNMENT CENTERED)
		     (FIXED_WIDTH TRUE)
		     (:EDIT (EDIT_WIDTH 1) (KEY "ps"))
		     (:TEXT (LABEL "-Φ"))
		     (:EDIT (KEY "d2"))
		    )
		    "spacer;"
		   )
		   "spacer;"
		  )
		  "spacer;"
		  "ok_cancel;"
		 )
		 "edit"
		 (:EDIT_BOX (ALLOW_ACCEPT TRUE) (EDIT_WIDTH 4))
		)
    )
    (fsxm-ldcl ldcl "dimhole")
  )
  ;;====
  (setq c1 (car enp))
  (cond	((and (= (fsxm-getendxf c1 0) "DIMENSION")
	      (= (fsxm-getendxf c1 70) 163)
	 )				;编辑模式
	 (setq str (fsxm-getendxf c1 1))
	 (setq htp (substr str 10 1))
	 (setq deep (vl-string-search "深" str))
	 (setq ps1 (vl-string-search "\\P" str))
	 (cond (deep
		(setq d1 (substr str 15 (- deep 14)))
		(setq deep (substr str (+ 3 deep) (- ps1 deep 2)))
	       )
	       (T
		(setq d1 (substr str 15 (- ps1 14)))
		(setq deep "")
	       )
	 )
	 (setq ps1 (vl-string-search "\\P" str))
	 (if (setq ps2 (vl-string-search "-" str))
	   (setq ps (substr str (+ ps1 3) (- ps2 ps1 2))
		 d2 (substr str (+ ps2 5))
	   )
	   (setq ps ""
		 d2 (substr str (+ ps1 6))
	   )
	 )
	 (setq txt (dimhole d1 d2 htp ps deep))
	 (if txt
	   (fsxm-setendxf c1 1 txt)
	 )
	)
	(t				;新增模式
	 (setq ss (ssget "X"
			 (list '(0 . "circle,arc")
			       (assoc 10 (entget c1))
			 )
		  )
	 )
	 (ssdel c1 ss)
	 (setq ps (sslength ss))
	 (cond ((= ps 0) (princ "\n没有搜索到对应的同心圆!"))
	       ((> ps 1) (princ "\n搜索到多个对应的同心圆!"))
	       ((= ps 1)
		(setq c2 (ssname ss 0))
		(setq sc (* 2 (getvar "dimlfac")))
		(setq d1 (rtos (* sc (fsxm-getendxf c1 40))
			       2
			       (getvar "dimdec")
			 )
		)
		(setq d2 (rtos (* sc (fsxm-getendxf c2 40))
			       2
			       (getvar "dimdec")
			 )
		)
		(if (setq txt (dimhole d1 d2 "v" "" ""))
		  (command ".dimdiameter" enp "t" txt)
		)
	       )
	 )
	)
  )
  (princ)
)