
;;;修改记录：由于zh_cvpt_len有问题，改为调用公用函数库中的HY_QXPMDJL,并删除了zh_cvpt_len的函数定义
;;;任蔚青修改．　2004-5-19 17:32
;;;已知一个实体和距离该实体起点的距离,求点
(defun zh_cvlen_pt (xc_ent    xc_dist	/	  w_etype   w_retp
		    w_sp      w_ep	w_len	  w_csb	    w_cp
		    w_r	      w_sang	w_eang	  w_mp	    w_ang
		    w_jp      w_rang	w_the_ang w_conl    w_ii
		    w_blen    w_iics	w_the_iics	    w_conl
		    w_curv    w_e_dist	w_iitype  var_tmp
		   )
  (szload $arc_csb "pppp")
  (szload &pl_en_cs "&@pp_zxp")
  (setq w_etype (cdr (assoc 0 (entget xc_ent))))
  (setq w_retp nil)
  (cond
    ((= w_etype "LINE")
     (setq w_sp	 (p# (cdr (assoc 10 (entget xc_ent))))
				   w_ep	 (p# (cdr (assoc 11 (entget xc_ent))))
				   w_len (pmdist w_sp w_ep)
     )
     (cond
       ((equal xc_dist 0.0 0.001)
				(setq w_retp w_sp)
       )
       ((equal xc_dist w_len 0.001)
				(setq w_retp w_ep)
       )
       ((or (< xc_dist 0.0) (> xc_dist w_len))
				(setq w_retp nil)
       )
       (t
				(setq w_retp (polar w_sp (angle w_sp w_ep) xc_dist))
       )
     )
    )
    ((= w_etype "ARC")
;;;cenp r ang1 ang2 sp ep midp ang len jp
     (setq w_csb ($arc_csb xc_ent))
     (setq w_cp	  (nth 0 w_csb)
				   w_r	  (nth 1 w_csb)
				   w_sang (nth 2 w_csb)
				   w_eang (nth 3 w_csb)
				   w_sp	  (nth 4 w_csb)
				   w_ep	  (nth 5 w_csb)
				   w_mp	  (nth 6 w_csb)
				   w_ang  (nth 7 w_csb)
				   w_len  (nth 8 w_csb)
				   w_jp	  (nth 9 w_csb)
     )
     (cond
       ((equal xc_dist 0.0 0.001)
				(setq w_retp w_sp)
       )
       ((equal xc_dist w_len 0.001)
				(setq w_retp w_ep)
       )
       ((or (< xc_dist 0.0) (> xc_dist w_len))
				(setq w_retp nil)
       )
       (t
				(setq w_rang	(/ xc_dist w_r)
				      w_the_ang	(+ w_sang w_rang)
				)
				(setq w_retp (polar w_cp w_the_ang w_r))
       )
     )
    )
    ((wcmatch w_etype "*POLYLINE")
     (setq w_csb (&pl_en_cs xc_ent))
     (setq w_conl 0.0
				   w_ii	  0
				   w_blen (length w_csb)
     )
     (while (< w_ii w_blen) ;;求出指定距离所在子实体数据表(("LINE" ps pe len_line)
                            ;;                             ("ARC" pc ps pe ans ane pm r v42 len_arc))
       (setq w_iics (nth w_ii w_csb))
       (setq w_conl (+ w_conl (last w_iics)))
       (if (<= xc_dist w_conl)
				 (setq w_ii w_blen
				       w_the_iics
							 w_iics
				 )
       )
       (setq w_ii (1+ w_ii))
     )
     ;;w_the_iics----指定距离所在子实体数据表   w_conl---指定距离前面所有子实体长度和(包括所在实体)
     (if w_the_iics
       (progn
				 (setq w_iitype (car w_the_iics))
				 (cond
				   ((= w_iitype "LINE")
				    (setq w_sp	   (cadr w_the_iics)
								  w_ep	   (caddr w_the_iics)
								  w_e_dist (- w_conl xc_dist)
								  w_retp   (polar w_ep (angle w_ep w_sp) w_e_dist)
				    )
				   )
				   ((= w_iitype "ARC")
				    (setq w_cp	   (nth 1 w_the_iics)
								  w_sp	   (nth 2 w_the_iics)
								  w_ep	   (nth 3 w_the_iics)
								  w_sang   (nth 4 w_the_iics)
								  w_eang   (nth 5 w_the_iics)
								  w_r	   (nth 7 w_the_iics)
								  w_curv   (nth 8 w_the_iics)
								  w_e_dist (- w_conl xc_dist)
								  w_rang   (/ w_e_dist w_r)
				    )
;;modify by谷德性 2001.12.14
				    (if (< w_curv 0.0)
				      (setq var_tmp w_sang   w_sang w_eang   w_eang var_tmp)
				    )
				    (if (< w_eang w_sang)  (setq w_eang (+ w_eang (* pi 2.0))) )

				    (if (< w_curv 0.0)
				      (setq w_retp (polar w_cp (+ w_sang w_rang) w_r))
				      (setq w_retp (polar w_cp (- w_eang w_rang) w_r))
				    )
;				    (if	(> w_curv 0.0)
;				      (setq w_the_ang (- w_eang w_rang))
;				      (setq w_the_ang (+ w_eang w_rang))
;				    )
;				    (setq w_retp (polar w_cp w_the_ang w_r))
				   )
				 )
       )
       (setq w_retp nil)
     )
    )
  )
  w_retp
)

;;;----------------------------------------------------------------
;;;判断一个选择集是否连续
;;;如果连续返回一个顺序链表
;;;否则返回空
(defun hy_ss_con (xc_ss	   xc_jd    xc_flag  /	      w_peb    w_ent
		  w_eb	   w_etyp   w_sp     w_ep     w_cp     w_r
		  w_spa	   w_epa    w_fent   w_item   w_outb   w_plen
		  w_osp	   w_oep    w_refb   w_goon   w_ii     w_blen
		  w_find   w_ang    w_pts    w_pte    w_ptb
		 )
;;;提取数据表w_peb((起点 实体 终点)...)
;;;忽略除LINE ARC POLYLINE LWPOLYLINE之外的实体
;;;  (zh_get_dimcfg)
  (while (> (sslength xc_ss) 0)
    (setq w_ent	 (ssname xc_ss 0)
	  w_eb	 (entget w_ent)
	  w_etyp (cdr (assoc 0 w_eb))
    )
    (ssdel w_ent xc_ss)
    (setq w_ptb	(bg-ypp w_ent)
	  w_sp	(last w_ptb)
	  w_ep	(car w_ptb)
	  w_peb	(cons (list w_sp w_ent w_ep) w_peb)
    )
  )

  
;;;把w_peb首尾相接
  (setq	w_item (car w_peb)
	w_outb (list w_item)
	w_peb  (cdr w_peb)
	w_plen (length w_peb)
	w_osp  (car w_item)
	w_oep  (last w_item)
	w_refb nil
  )
  
  
  
  (if w_peb
    (setq w_goon 1)
    (setq w_goon 0)
  )
  
  (while (= w_goon 1)
    (setq w_find (car w_peb)
	  w_peb	 (cdr w_peb)
	  w_sp	 (car w_find)
	  w_ep	 (last w_find)
    )
	   
;;;判断w_find是否能链接到w_outb
    (cond
      ((< (pmdist w_sp w_ep) xc_jd)
       nil
      )
      ((< (pmdist w_sp w_osp) xc_jd)
;;;w_find的起终点交换位置后链接到w_outb头部
;;;输出表的头部w_osp更新为w_ep

       (if (< (pmdist w_ep (last (car w_outb))) xc_jd)
           nil
          (setq w_outb (cons (list w_ep (cadr w_find) w_sp) w_outb)
	     w_osp  w_ep
          )
       );;;if
      )
      ((< (pmdist w_ep w_osp) xc_jd)

;;;w_find链接到w_outb头部
;;;输出表的头部w_osp更新为w_sp
       (if (< (pmdist w_sp (last (car w_outb))) xc_jd)
           nil 
	   (setq w_outb (cons w_find w_outb)
	         w_osp  w_sp
	   )
       );;;if
      )
      ((< (pmdist w_sp w_oep) xc_jd)

;;;w_find链接到w_outb尾部
;;;输出表的尾部w_oep更新为w_ep
       (if (< (pmdist w_ep (car (last w_outb))) xc_jd)
           nil
          (setq w_outb (append w_outb (list w_find))
	     w_oep  w_ep
          )
       );;;if
      )
      ((< (pmdist w_ep w_oep) xc_jd)
 
;;;w_find的起终点交换位置后链接到w_outb尾部
;;;输出表的尾部w_oep更新为w_sp
     
       (if (< (pmdist w_sp (car (last w_outb))) xc_jd)
           nil
          (setq w_outb (append w_outb (list (list w_ep (cadr w_find) w_sp)))
	     w_oep  w_sp
          )
       );;;if
      )
      (t
;;;不能链接,w_find加入另表
       (setq w_refb (cons w_find w_refb))
      )
    )
    
;;;end of 判断w_find是否能链接到w_outb
;;;判断父表w_peb是否已经空

    (if	(null w_peb)
      (progn
	(if (or (null w_refb) (= (length w_refb) w_plen))
	  (setq	w_goon 0
		w_peb  w_refb
	  )
	  (setq	w_peb  w_refb
		w_plen (length w_peb)
		w_refb nil
	  )
	)
      )
    )
  )

;;任蔚青修改2003-6-26 9:32,将小短线的处理移到前面
;;;;;2002/7/29谷德性增加
;;;去掉表中长度小于判断精度的实体
;;  (if (> (length w_peb) 0)
;;    (progn
;;       (setq wb_tmp_rwq nil)
;;       (foreach ent_tmp_rwq w_peb
;;           (setq w_sp (car ent_tmp_rwq) w_ep (nth 2 ent_tmp_rwq))
;;           (if (not (<= (pmdist w_sp w_ep) xc_jd))
;;             (setq wb_tmp_rwq (cons ent_tmp_rwq wb_tmp_rwq))
;;           )
;;       )
;;       (setq w_peb wb_tmp_rwq)
;;    )
;;  )
 ;;;;;2002/7/29谷德性增加

;;;;任蔚青修改2003-6-26 9:32,对于不能定义的选择集,不绘制矢量圆提示,图面上能从颜色区分
;;;判断父表w_peb是否已经取空

;;  (if (> (length w_peb) 0)
;;    (progn
;;      (setq w_outb nil)
;;      (setq w_ang (angle w_osp w_oep)
;;	    w_pts (polar w_osp (+ pi w_ang) 2)
;;	    w_pte (polar w_oep w_ang 2)
;;      )
;;      (cond
;;	((= xc_flag 0))
;;	((= xc_flag 1)
;;	 (command "_.zoom" pts pte)
;;	 (#mark w_osp)
;;	 (#mark w_oep)
;;	 (alert
;;	   "程序发现:\n
;;在图中圆形标志所指示的两点中,\n
;;至少在其中一点,您所选择的实体在精度范围内不连续!!!\n
;;请您局部放大后仔细校正!"
;;	 )
;;	)
;;	((= xc_flag 2)
;;	 (command "_.zoom" pts pte)
;;	 (#mark w_osp)
;;	 (#mark w_oep)
;;	 (alert
;;	   "程序发现:\n
;;在图中圆形标志所指示的两点中,\n
;;至少在其中一点,桩号线在精度范围内不连续!!!\n
;;请您局部放大后仔细校正并重定桩号!"
;;	 )
;;	)
;;      )
;;    )
;;  )
;;;  (zh_nil_dimcfg)
  w_outb
)
;;;--------------------------------------
(defun zh_get_zhn (xc_ent)
  (caadr (assoc -3 (entget xc_ent (list "DLZH_*"))))
)

(defun zh_get_roadn (xc_ent / w_rdn)
  (setq w_zhn (zh_get_zhn xc_ent))
  (setq w_rdn (HY_QQ10xx xc_ent w_zhn 1000))
)
;;;=======================================================
;;;-------------------------------------------------
;;;对链表排序使链表的点序与桩号顺序一致
(defun zh_lnkb_px (xc_lnkb   xc_prec   /	 w_blen	   w_retb
		   w_fitm    w_fent    w_zhn	 w_bitm	   w_bent
		   w_fzhb    w_bzhb    w_fczh	 w_bczh	   w_dirc
		  )
  (setq w_blen (length xc_lnkb))
  (cond
    ((= w_blen 0)
     	(setq w_retb nil)
    )
    ((= w_blen 1)
	     (setq w_fitm (car xc_lnkb)
		   w_fent (cadr w_fitm)
		   w_zhn  (zh_get_zhn w_fent)
		  	)
		  	(if w_zhn
					(progn
					   (setq w_dirc (HY_QQ10xx w_fent w_zhn 1070) )
				     (if (= w_dirc 1)
				       (setq w_retb xc_lnkb)
				       (setq w_retb (mapcar 'reverse xc_lnkb))
				     )
	    		)
	    		(setq w_retb xc_lnkb)
	 		 )
    )
    ((> w_blen 1)
	     (setq w_fitm (nth 0 xc_lnkb)
		   w_fent (cadr w_fitm)
		   w_zhn  (zh_get_zhn w_fent)
		   )
			(if w_zhn
				(progn
				   (setq w_bitm (nth 1 xc_lnkb)
				   w_bent (cadr w_bitm)
				   w_fzhb (HY_QQ10xx w_fent w_zhn 1010)
				   w_bzhb (HY_QQ10xx w_bent w_zhn 1010)
				   w_fczh (cadr w_fzhb)
				   w_bczh (car w_bzhb)
			     )
			
			     (if (equal w_fczh w_bczh xc_prec)
			       (setq w_retb xc_lnkb)
			       (setq w_retb (reverse (mapcar 'reverse xc_lnkb)))
			     )
	    	)
	    	(setq w_retb xc_lnkb)
	    )
    )
  )
  w_retb
)
;;;[2003/7/28]

;;;-------------------------------------
;;;任蔚青修改 2003-6-6 10:50
;;;修改原来的找桩号点的算法,原来查找方法为从头到尾查找,效率极低,遇到长路会死机
;;;改为二分法搜索,增加一个局部函数divide_two
;;;由桩号、顺序链表提取桩号点、正方向、桩号所在实体
(defun zh_get_pde (xc_zh    xc_lnkb  xc_prec  /	       w_ii
		   w_blen   w_item   w_fent   w_head   w_tail
		   w_zhn    w_fzhb   w_bbzh   w_fzh    w_bzh
		   w_fbzh   w_eb     w_etyp   w_endp   w_sp
		   w_ep	    w_zhp    w_dist   w_se_ang w_cenp
		   w_jang   w_btb    w_svp    w_evp    w_v42
		   w_retb   w_pcr    item_b item_e  divide_two
		  )

  
      (setq item_b 0
            w_blen (length xc_lnkb)
            item_e (- w_blen 1)
       )

;;;;;用二分法找桩号所在实体在中心线实体链表中的索引号
   (defun divide_two(item_b item_e / list_b list_e
       zhb_b    zhb_e    zh_min_b   zh_max_b zh_min_e 
       zh_max_e item     flag 
       )

   (setq item nil)
   (setq flag nil);;;是否在该段内


   (setq list_b (cadr (nth item_b xc_lnkb))
         list_e (cadr (nth item_e xc_lnkb))
   )

   (setq zhb_b  (HY_QQ10xx list_b (zh_get_zhn list_b) 1010)
         zhb_e  (HY_QQ10xx list_e (zh_get_zhn list_e) 1010)
         zh_min_b (car zhb_b) zh_max_b (cadr zhb_b)
         zh_min_b (min zh_min_b zh_max_b)
         zh_max_b (max zh_min_b zh_max_b)
         zh_min_e (car zhb_e) zh_max_e (cadr zhb_e)
         zh_min_e (min zh_min_e zh_max_e)
         zh_max_e (max zh_min_e zh_max_e)
   )

   (if (and (or (equal xc_zh zh_min_b xc_prec)  (> xc_zh zh_min_b)) (or (equal xc_zh zh_max_e xc_prec)  (< xc_zh zh_max_e))) 
       (setq flag t);;;在这一段内
   )

   (if  flag
     (progn
       (cond
        ((= item_e item_b)
          (setq item item_b)
        )
        ((and (or (equal xc_zh zh_min_b xc_prec)  (> xc_zh zh_min_b)) (or (equal xc_zh zh_max_b xc_prec)  (< xc_zh zh_max_b))) 
         (setq item item_b)
        )
        ((and (or (equal xc_zh zh_min_e xc_prec)  (> xc_zh zh_min_e)) (or (equal xc_zh zh_max_e xc_prec)  (< xc_zh zh_max_e))) 
         (setq item item_e )
        )
        (t 
           (if (> item_e item_b)
               (progn
                  (setq item_c (+ item_b (/ (- item_e item_b) 2)))
                  (if (not (or (setq  item (divide_two item_b item_c)) (setq  item (divide_two item_c item_e))))
                      (setq item nil)
                  )
               )
               (setq item nil)
           )
        )
       
       );;;cond
     );;;progn
     (setq item nil)
   )
   item
 );;;;defun

(if (= w_blen 1) (setq w_item  item_b) (setq w_item (divide_two item_b item_e)))
(if w_item
;;;如果桩号在链表覆盖的范围内
    (progn
      (setq w_item (nth w_item xc_lnkb))
      (setq w_fent (cadr w_item)
;;;链表节点的实体
				  w_head (car w_item)
;;;链表节点的头点
				  w_tail (last w_item)
;;;链表节点的尾点
				  w_zhn	 (zh_get_zhn w_fent)
;;;桩号数据扩展名
				  w_fzhb (HY_QQ10xx w_fent w_zhn 1010)
;;;桩号扩展数据
				  w_bbzh (HY_QQ10xx w_fent w_zhn 1040)
;;;桩号断链去向里程
				  w_fzh	 (car w_fzhb)
;;;链头桩号--小
				  w_bzh	 (cadr w_fzhb)
;;;链尾桩号--大
				  w_fbzh (caddr w_fzhb)
;;;来向断链里程
      )
      (setq w_eb   (entget w_fent)
				    w_etyp (cdr (assoc 0 w_eb))
				    w_endp (bg-ypp w_fent)
				    w_sp   (p# (last w_endp))
				    w_ep   (p# (car w_endp))
      )
;;;求桩号点
      (cond
				((equal xc_zh w_fzh xc_prec)
				 (setq w_zhp w_head)
				)
				((equal xc_zh w_bzh xc_prec)
				 (setq w_zhp w_tail)
				)
				(t
				 (if w_bbzh
			;;;如果有断链
				   (progn
     			     (cond
				       ((or (equal xc_zh w_fbzh xc_prec)
								    (equal xc_zh w_bbzh xc_prec)
								)
						;;;正好是断链点

								(if (equal w_sp w_head xc_prec)
								  (setq w_dist (- w_fbzh w_fzh))
								  (setq w_dist (- w_bzh w_bbzh))
								)
							       )
							       ((< xc_zh w_fbzh)

						;;;桩号点在来向里程段
								(if (equal w_sp w_head xc_prec)
								  (setq w_dist (- xc_zh w_fzh))
								  (setq w_dist (+ (- w_fbzh xc_zh) (- w_bzh w_bbzh)))
								)
							       )
							       ((> xc_zh w_bbzh)
              	;;;桩号点在去向里程段
								(if (equal w_sp w_head xc_prec)
								  (setq w_dist (+ (- w_fbzh w_fzh) (- xc_zh w_bbzh)))
								  (setq w_dist (- w_bzh xc_zh))
								)
				       )
				       (t (setq w_dist nil))
				     )
				   )
				   (progn

				     (if (equal w_sp w_head xc_prec)
				       (setq w_dist (- xc_zh w_fzh))
				       (setq w_dist (- w_bzh xc_zh))
				     )
				   )
				 )
			;;;end if w_bbzh
				 (if w_dist
				   (setq w_zhp (zh_cvlen_pt w_fent w_dist))
				   (setq w_zhp nil)
				 )
				)
      );;;end of cond ;;;求桩号点
      ;;;求该点正方向
      (if w_zhp
				(progn
				  (cond
				    ((= w_etyp "LINE")
				     (setq w_se_ang (angle w_head w_tail))
				    )
				    ((= w_etyp "ARC")
				     (setq w_cenp (cdr (assoc 10 w_eb))
								   w_jang (angle w_cenp w_zhp)
								   w_jang (+ w_jang (* 0.5 pi))
				     )
				     (if (equal w_sp w_head xc_prec)
				       (setq w_se_ang w_jang)
				       (setq w_se_ang (+ pi w_jang))
				     )
				    )
				    ((or (= w_etyp "LWPOLYLINE") (= w_etyp "POLYLINE"))
				     (setq w_btb (dw-ypp1 w_fent w_zhp)
								   w_svp (cadr w_btb)
								   w_evp (caddr w_btb)
								   w_v42 (cadddr w_btb)
				     )
				     (if (= w_v42 0.0)
				       (setq w_se_ang (angle w_svp w_evp))
				       (progn
								 (setq w_pcr  (parc_pcr w_svp w_evp w_v42)
								       w_cenp (car w_pcr)
								 )
								 (setq w_se_ang (+ (angle w_cenp w_zhp) (* 0.5 pi)))
								 (if (< w_v42 0)
								   (setq w_se_ang (+ w_se_ang pi))
								 )
				       )
				     )
			;;;end (if (= w_v42 0.0)
				     (if (not (equal w_sp w_head xc_prec))
				       (setq w_se_ang (+ w_se_ang pi))
				     )
				    )
				  )
				  (while (> w_se_ang (* 2.0 pi))
				    (setq w_se_ang (- w_se_ang (* 2.0 pi)))
				  )
				)
      )
      (if w_zhp
				(setq w_retb (list w_zhp w_se_ang w_fent))
				(setq w_retb nil)
      )
    )
   
    (setq w_retb nil)
  )
  w_retb
)

(defun zh_get_dimcfg (/ w_stk_set w_set_list w_key)
  (if (null (setq w_stk_set (DL_GetPrjVal "PLN_STK_SET")))
    (setq w_stk_set "1000 50 1 0 1 0 1 1 K 0 0 0 0 0")
  )
  (setq w_set_list (HY_SeparateString w_stk_set))
  (setq
;;;工程精度
    w::prec	 0.001
;;;桩号系统
    w::stk_sys	 (atoi (nth 0 w_set_list))
;;;整桩间隔
    w::stk_intvl (atoi (nth 1 w_set_list))
;;;非整桩号只标尾数
    w::only_tail (atoi (nth 2 w_set_list))
;;;头部用零补齐
    w::f_zero	 (atoi (nth 3 w_set_list))
;;;尾部整数位用零补齐
    w::b_zero	 (atoi (nth 4 w_set_list))
;;;尾部小数位用零补齐
    w::t_zero	 (atoi (nth 5 w_set_list))
;;;整数桩号不要小数位
    w::nodot	 (atoi (nth 6 w_set_list))
;;;是否标注字头
    w::add_prf	 (atoi (nth 7 w_set_list))
;;;标注字头
    w::prefix	 (nth 8 w_set_list)
;;;是否标注桩号代号
    w::add_code	 (atoi (nth 9 w_set_list))
;;;标注方式
    w::dim_mode	 (atoi (nth 10 w_set_list))
;;;标注自然高
    w::dim_zrg	 (atoi (nth 11 w_set_list))
;;;标注设计高
    w::dim_sjg	 (atoi (nth 12 w_set_list))
  )
  
  (if (> (length w_set_list) 13)
;;;是否自动标注桩号
      (setq w::auto_dim	(atoi (nth 13 w_set_list)))
      (setq w::auto_dim 0)
  )
  
  (setq w_key (strcat "PLN_STKDIM_M" (itoa w::dim_mode)))
  (if (null (setq w_stk_set (DL_GetPrjVal w_key)))
    (progn
      (DL_MsgOK "系统文件被破坏,请重新恢复系统文件!")
      (exit)
    )
  )
  (setq w_set_list (HY_SeparateString w_stk_set))
  (cond
    ((= w::dim_mode 0)
;;;居中标注
     (setq
;;;文字方向--大桩号还是小桩号侧
       w::text_d    (atoi (nth 0 w_set_list))
;;;小短线长
       w::liner_len (atof (nth 1 w_set_list))
;;;小短线宽
       w::liner_wid (atof (nth 2 w_set_list))
     )
     (if (= (length w_set_list) 5)
       (setq
         ;;;是否用小短线作为标注符号
          w::flag_line (atoi (nth 3 w_set_list))
         ;;;文字方向是否垂直于道路方向
          w::text_prep (atoi (nth 4 w_set_list))
       )
       (setq 
          ;;;用小短线作为标注符号
             w::flag_line 0
          ;;;文字方向垂直于道路方向
             w::text_prep 0
       )
     )
    )
    ((or (= w::dim_mode 1) (= w::dim_mode 2))
;;;左侧标注和右侧标注
;;(princ "\nw_set_list = ")(princ w_set_list)
     (setq
;;;文字方向--大桩号还是小桩号侧
       w::text_d    (atoi (nth 0 w_set_list))
;;;小短线与桩线的间距
       w::offset    (atof (nth 1 w_set_list))
;;;小短线与文本的间距
       w::line_txt  (atof (nth 2 w_set_list))
;;;小短线长
       w::liner_len (atof (nth 3 w_set_list))
;;;小短线宽
       w::liner_wid (atof (nth 4 w_set_list))
     )
     (if (= (length w_set_list) 7)
       (setq
         ;;;是否用小短线作为标注符号
          w::flag_line (atoi (nth 5 w_set_list))
         ;;;文字方向是否垂直于道路方向
          w::text_prep (atoi (nth 6 w_set_list))
       )
       (setq 
          ;;;用小短线作为标注符号
             w::flag_line 0
          ;;;文字方向垂直于道路方向
             w::text_prep 0
       )
     )
    )
    ((or (= w::dim_mode 3) (= w::dim_mode 4))
    ;;(princ "\nw_set_list = ")(princ w_set_list)
;;;左侧路外标注和右侧路外标注
     (setq
;;;文字方向--大桩号还是小桩号侧
       w::text_d    (atoi (nth 0 w_set_list))
;;;小短线与路边线的间距
       w::offset    (atof (nth 1 w_set_list))
;;;小短线与文本的间距
       w::line_txt  (atof (nth 2 w_set_list))
;;;小短线长
       w::liner_len (atof (nth 3 w_set_list))
;;;小短线宽
       w::liner_wid (atof (nth 4 w_set_list))
     )
     (if (= (length w_set_list) 7)
       (setq
         ;;;是否用小短线作为标注符号
          w::flag_line (atoi (nth 5 w_set_list))
         ;;;文字方向是否垂直于道路方向
          w::text_prep (atoi (nth 6 w_set_list))
       )
       (setq 
          ;;;用小短线作为标注符号
             w::flag_line 0
          ;;;文字方向垂直于道路方向
             w::text_prep 0
       )
     )
    )
    ((or (= w::dim_mode 5) (= w::dim_mode 6))
;;;左侧引出标注和右侧引出标注
     (setq
;;;文字方向--大桩号还是小桩号侧
       w::text_d (atoi (nth 0 w_set_list))
;;;引出线延伸距离
       w::offset (atof (nth 1 w_set_list))
     ) 
     (if (= (length w_set_list) 4)
         (setq 
          ;;;是否用小短线作为标注符号
             w::flag_line (atoi (nth 2 w_set_list))
          ;;;文字方向是否垂直于道路方向
             w::text_prep (atoi (nth 3 w_set_list))
         )
         (setq 
          ;;;用小短线作为标注符号
             w::flag_line 0
          ;;;文字方向垂直于道路方向
             w::text_prep 0
         )
     )
     	;;1 小桩号侧标注大桩号侧标注  w::text_d
	;;2 引出线延伸长度            w::offset
	;;3 引出线从中心线引出        w::offsetNoRoadWid 0 - 延伸长度不加路宽 1 - 延伸长度加路宽   （05/04/19 Add）
	;;4 引出线距离中桩距离        w::offsetIsAxisDist 当 w::offsetIsAxis 是 1时此值有效  05/04/19 Add）
	;;5 标志:短线 十字            w::flag_line
	;;6 文字方向                  w::text_prep
	;;7 是否加圆标志 	      w::IsAddCircle 0 - 不加 1 - 加  （05/04/19 Add）
	;;8 圆标志的半径	      w::CircleRadius                  05/04/19 Add）
	(if (= (length w_set_list) 8)
		(progn
			(setq w::offsetNoRoadWid (atoi (nth 2 w_set_list)))
			(setq w::offsetIsAxisDist (atof (nth 3 w_set_list)))
			(setq w::flag_line (atoi (nth 4 w_set_list)))
			(setq w::text_prep (atoi (nth 5 w_set_list)))
			(setq w::IsAddCircle (atoi (nth 6 w_set_list)))
			(setq w::CircleRadius (atof (nth 7 w_set_list)))
		)
		(progn
			(setq w::offsetNoRoadWid 1)
			(setq w::offsetIsAxisDist 0.0)
			(setq w::IsAddCircle 0)
			(setq w::CircleRadius 0.0)
		)
	)
    )
    (t
     (setq w_key "PLN_STKDIM_M0")
     (if (null (setq w_stk_set (DL_GetPrjVal w_key)))
       (progn
	 (DL_MsgOK "系统文件被破坏,请重新恢复系统文件!")
	 (exit)
       )
     )
     (setq w_set_list (HY_SeparateString w_stk_set))
     ;;;居中标注
     (setq
;;;文字方向--大桩号还是小桩号侧
       w::text_d    (atoi (nth 0 w_set_list))
;;;小短线长
       w::liner_len (atof (nth 1 w_set_list))
;;;小短线宽
       w::liner_wid (atof (nth 2 w_set_list))
     )
     (if (= (length w_set_list) 5)
         ;;;是否用小短线作为标注符号
         (setq w::flag_line (atoi (nth 3 w_set_list))
         ;;;文字方向是否垂直于道路方向
               w::text_prep (atoi (nth 4 w_set_list))
         )
         (setq 
          ;;;用小短线作为标注符号
             w::flag_line 0
          ;;;文字方向垂直于道路方向
             w::text_prep 0
         )
     )
    )
  )
  (setq
;;;文字高
    w::txth (Dl_GetTextHeight)
;;;图纸比例
    w::sca  (DL_GetDrawingFactor)
;;;小数保留位数
    w::frct (DL_GetDimPrec)
  )
;;;文字与尺寸线的间距
  (if (null (setq w::bottom_d (DL_GetPrjVal "DIM_COMM_SET")))
    (setq w::bottom_d 0.5)
  )
)
(defun zh_nil_dimcfg ()
  (setq
    w::prec nil
    w::stk_sys
     nil
    w::stk_intvl
     nil
    w::f_zero nil
    w::b_zero nil
    w::t_zero nil
    w::nodot nil
    w::add_prf
     nil
    w::prefix nil
    w::add_code
     nil
    w::dim_mode
     nil
    w::dim_sjg
     nil
    w::only_tail
     nil
    w::dim_zrg
     nil
    w::auto_dim
     nil
  )
  (setq
    w::text_d nil
    w::offset nil
    w::line_txt
     nil
    w::liner_len
     nil
    w::liner_wid
     nil
    w::flag_line nil
    w::text_prep nil
  )
  (setq
    w::txth nil
    w::sca nil
    w::frct nil
  )
  (setq
    w::bottom_d
     nil
  )
  (setq
    w::offsetNoRoadWid nil
    w::offsetIsAxisDist nil
    w::IsAddCircle nil
    w::CircleRadius nil
  )
)
