;;;纵断面绘制--11/25/2000
;;;代码编写 -- 汪洪涛
;;;Lxf 2003.2.25修改
;;;GB 50162-92
;;;============================主函数==========================================
;;;为了提高速度和减少系统开销在主函数中定义了大量的全局变量供子函数调用
;;;全局变量
;;;wg_sca                 全图的比例系数
;;;wg_txth                考虑全图的比例系数以后的统一字高
;;;wg_soft_path           软件的安装目录
;;;wg_user_path           using目录所在的路径
;;;wg_thickness           结构层厚度
;;;wg_h_wid               表头宽度
;;;wg_htxt_h              表头字高
;;;wg_htxt_j              文字对齐
;;;wg_rule_uh             标尺顶高
;;;wg_rule_dh             标尺底高
;;;wg_h_hsc               横向比例
;;;wg_h_vsc               竖向比例
;;;wg_slp_mode            坡度模式
;;;wg_sqx_step            竖曲加密间距
;;;wg_rule_ah             标尺总高
;;;wg_valid_rule          标尺的有效标高高差
;;;wg_xscale              横向放缩系数
;;;wg_xscale              竖向放缩系数
;;;wg_p00_x               表头基点相对于图框左下角的x偏移量
;;;wg_p00_y               表头基点相对于图框左下角的y偏移量
;;;wg_off_x              标尺与网格距离
;;;wg_off_y	      标尺与表头距离
;;;wg_north_dang          北方向角(度)
;;;wg_head_bp             表头基点
;;;wg_items_bp            栏基点
;;;wg_rule_bp             标尺基点
;;;wg_net_bp              网格基点

;;;wg_sjx_layer           设计地面线层
;;;wg_zrx_layer           自然地面线层
;;;wg_btbc_layer          表头标尺层
;;;wg_wg_layer            网层
;;;wg_bldim_layer         分栏线层
;;;wg_sqxdim_layer        竖曲线(变坡点)标注层
;;;
;;;wg_Textdim_layer        栏文字标注层
;;;wg_JCKdim_layer        交叉口标注层
;;;wg_pmdim_layer        平面线形标注层
;;;wg_road_name           道路名称


;;;L_IsDimSjxZrx           是否标注设计线自然线0---不标注 1----标注
;;;wg_biaotoushuxian      是否绘制表头竖线0---绘制 1----不绘制
;;;wg_txtoffset           栏标注文字距离竖线的距离
(defun hyzdmdgn	(/		 w_file		 w_fn
		 w_base_para	 w_value	 w_item
		 w_head_h	 w_head_item	 w_ll_dist
		 w_min_zrzh	 w_max_zrzh	 w_min_zh
		 w_max_zh	 w_fint_zh	 w_sstk
		 	 w_sep_zhlen	 w_sep_zhlist
		 w_first_zh	 w_sqx		 w_fzh
		 w_bzh		 w_zh		 w_counter
		 w_all_count	 w_min_sjzh	 w_pre_zh
		 w_pre_bg	 w_pre_thiszh	 w_pre_thisbg
		 w_ch_zhlist	 w_ch_bglist	 w_flag
		 w_this_zhlist	 w_this_bglist	 w_init_bg
		 w_max_bg	 w_min_bg	 w_pgc
		 w_ngc		 w_bg		 wg_rule_bg0
		 w_zh_range	 w_max_sjzh	 wg_thickness
		 wg_basp	 wg_sca		 wg_txth
		 wg_head_items	 wg_h_wid	 wg_htxt_h
		 wg_htxt_j	 wg_rule_uh	 wg_rule_dh
		 wg_h_hsc	 wg_h_vsc	 
		 wg_slp_mode	 wg_biaotoushuxian	 
		 wg_sqx_step	 wg_rule_ah
		 wg_valid_rule	 wg_xscale	 wg_yscale
		 wg_p00_x	 wg_p00_y	 wg_off_x wg_off_y
		 wg_north_dang	 wg_zrbg_list	 wg_sjbg_list
		 wg_dim_zhlist	 wg_dim_bglist	 wg_ffzh
		 wg_bbzh	 wg_head_bp	 wg_items_bp
		 wg_rule_bp	 wg_net_bp	 wg_care_first
		 wg_first_zh	 wg_draw_step	 wg_bgz_file	 wg_jd_file		wg_zddata_file
		 wg_bgs_file	 wg_sjx_layer	 wg_zrx_layer
		 wg_btbc_layer	 wg_wg_layer	 wg_bldim_layer
		 wg_Textdim_layer wg_JCKdim_layer wg_pmdim_layer wg_qx_layer
		 wg_sqxdim_layer wg_sjg_zd	 w_the_zh
		 w_section_szh	 w_section_ezh	 wg_dim_zrbglist
		 w_ch_zrbglist	 w_pre_zrbg	 w_pre_thiszrbg
		 w_index	 w_item_wid	 w_item_prec w_item_0bq    ;; 1 - 小数位用0补齐 0 - 小数位不用0不取
		 w_item_basp	 w_kl_dbgb	 w_kl_dbg   w_kl_dbgb_Temp ;;存放w_kl_dbgb的临时变量
		 w_kl_bgstr	 w_jbg		 w_this_zrbglist
		 w_is_maxbg	 w_is_minbg	 wg_pqxb
		 wg_soft_path    wg_user_path    w_tkptb
                 wg_addzh_jd
		 L_ssMainRoad     L_ssZhDim    L_zhCode
		 L_AppName   L_glb  L_entName1   L_entName2
		 L_zhcsb  L_nIndex   L_entData  L_Pt   L_Zh
		 L_pmbzzhList   L_strText  L_zdmDrawList
		 L_DrawZhList              ;;要绘制的桩号表--
		 Lg_HaveBz_ZhList          ;;有备注的桩号和备注表--
		 L_Temp L_TempStr
		 L_htcsList                ;;绘图参数表
		 L_basecsList              ;;基本参表
		 L_twgIsHJgc               ;;填挖高是否含结层
		 L_IsDrawWg                ;;是否绘制网格-
		 L_IsDrawSx                ;;是否绘制竖线-
		 L_tkcsb                   ;;图框参数表(图幅 长 宽)-
		 L_bgcvalide_Flag          ;;nil同一桩号的设计标高和自然标高差大于标尺的有效范围-
	      			           ;;t ...高差在有效范围内-
		 L_ZrbgFirst     L_ZrbgSecond
		 L_is_maxbg_Zr   L_is_minbg_Zr
		  t_angle t_height t_kgb
		 t_horzon t_vertical vertical
		 w_ssAxis  w_pt
		 sub_jck_list
		 L_retListTk
		 L_ptInnerLL
		 tempZhList  tempzh1  tempZh ;;在桩号列表中将非常相近的两个桩号，保留特征桩，删除整桩时添加的3个变量
		 ;;w_DZGKList ;;地质概况
		 IsNil ;;创建层是否成功
		 wg_road_name  ;;道路名称
		 wg_txtoffset  ;; 栏标注文字距离竖线的距离
		 w_str_zh      ;;
		 zrxent sjxent
		 L_IsDimSjxZrx ;;标注自然线设计线 
		)
	
  (dl_arxload "pm_line")
  (szload pub_save_var "wwpublic")
  (szload zh_zhtodim "hy_dlzh")
  (szload Draw_Tk "hyszdlsz")
  (#ppas "ZdmDsgn")
  (#ppas "drawroad")
  (pub_save_var)
  (command "layer" "t" "0" "u" "0" "on" "0" "")
;;;得到基点
;;;wg_sjx_layer           设计地面线层
;;;wg_zrx_layer           自然地面线层
;;;wg_btbc_layer          表头标尺层
;;;wg_wg_layer            网层
;;;wg_bldim_layer         分栏线层
;;;wg_sqxdim_layer        竖曲线(变坡点)标注层
;;;
;;;wg_Textdim_layer        栏文字标注层
;;;wg_JCKdim_layer        交叉口标注层
;;;wg_pmdim_layer        平面线形标注层
  (setq	wg_sjx_layer	"纵断_设计线" ;;"SZ-ZD-LMX"
	wg_zrx_layer	"纵断_地面线" ;;"SZ-ZD-ZRX"
	wg_wg_layer	"纵断_高程网格" ;; "SZ-ZD-WG"
	wg_btbc_layer    "纵断_表头"   ;;; 表头标尺层
	wg_bldim_layer   "纵断_分栏线"      ;;;分栏线层
	wg_sqxdim_layer  "纵断_变坡点"     ;;; 竖曲线(变坡点)标注层
	wg_Textdim_layer   "纵断_分栏文字"    ;;; 栏文字标注层
	wg_JCKdim_layer    "纵断_交叉口"    ;;;交叉口标注层
	wg_pmdim_layer     "纵断_平面线形"   ;;;平面线形标注层
	wg_sjg_zd  "纵断_标注" ;;"SZ-ZD-ZDBZ"
	wg_qx_layer "纵断_切线"  ;;纵断设计线切线
        wg_addzh_jd 5.0
  )
  
  (setq IsNil (DL_MakeLayer wg_sjx_layer))
  (if (= IsNil nil)
      (setq wg_sjx_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_zrx_layer))
  (if (= IsNil nil)
      (setq wg_zrx_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_btbc_layer))
  (if (= IsNil nil)
      (setq wg_btbc_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_bldim_layer))
  (if (= IsNil nil)
      (setq wg_bldim_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_Textdim_layer))
  (if (= IsNil nil)
      (setq wg_Textdim_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_JCKdim_layer))
  (if (= IsNil nil)
      (setq wg_JCKdim_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_zrx_layer))
  (if (= IsNil nil)
      (setq wg_zrx_layer "PP-COM")
  )

  (setq IsNil (DL_MakeLayer wg_wg_layer))
  (if (= IsNil nil)
      (setq wg_wg_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_sqxdim_layer))
  (if (= IsNil nil)
      (setq wg_sqxdim_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_pmdim_layer))
  (if (= IsNil nil)
      (setq wg_pmdim_layer "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_sjg_zd))
  (if (= IsNil nil)
      (setq wg_sjg_zd "PP-COM")
  )
  
  (setq IsNil (DL_MakeLayer wg_qx_layer))
  (if (= IsNil nil)
      (setq wg_qx_layer "PP-COM")
  )
;;Lxf add 2003.2.22
;;;下面得到平面标注桩号传给(arx_zdmdraw)
  (if (null &pp_zxpx2)
     (#ppls "&@pp_zxp")
  )

  (setq L_zhCode (DL_GetMainStake)
  )
  (setq L_pmbzzhList nil);;
  (setq L_zdmDrawList (arx_zdmdraw))    ;;;得到绘制参数
 (if L_zdmDrawList
	 (setq L_DrawZhList (nth 2 L_zdmDrawList)    ;;;;桩号列表
	       L_basecsList (nth 0 L_zdmDrawList)
	       L_htcsList   (nth 1 L_zdmDrawList)
	       wg_road_name (nth 1 L_basecsList)
	       wg_bgz_file  (nth 2 L_basecsList);;自然标高文件
	       wg_bgs_file  (nth 3 L_basecsList);;设计标高文件-
		   wg_jd_file  (nth 4 L_basecsList);;鸿叶交点文件
		   wg_zddata_file (nth 5 L_basecsList);;纵断综合数据文件
	 )
   	(setq L_DrawZhList nil)
 ) 
 
 ;;;得到交叉口桩号以及中心线角度，已经排过序
 (setq wg_jck_list (get_jck L_zhCode))
 ;;;读取自然标高数据--wg_zrbg_list
 (if (/= wg_bgz_file nil)
      (setq wg_zrbg_list (arx_readbgz wg_bgz_file))
 ) 
;;;读取设计标高数据--wg_sjbg_list
;;; 0  1--前一变坡点存在
;;; 1  1--后一变坡点存在
;;; 2  1--竖曲线半径存在
;;; 3  1--变坡点的索引号
;;; 4  该变坡点的桩号
;;; 5  该变坡点的标高
;;; 6  该变坡点的竖曲线半径 R
;;; 7  前一变坡点的桩号
;;; 8  前一变坡点的标高
;;; 9  后一变坡点的桩号
;;;10  后一变坡点的标高
;;;11  竖曲线元素 E
;;;12  竖曲线元素 T
;;;13  竖曲线起点桩号
;;;14  竖曲线终点桩号
;;;15  该变坡点的坡差
(if (/= wg_bgs_file nil)
  (setq wg_sjbg_list (arx_readbgs wg_bgs_file))
) 
  (if (and L_DrawZhList wg_sjbg_list)
    (setq wg_basp (getpoint "\n 回车退出 / 点取首幅图图框左下角:"))
    (setq wg_basp nil)
  )
  (if wg_basp 
    (progn
    	(setq jck_index 1)
      ;;;找出有备注的桩号Lg_HaveBz_ZhList
      (setq Lg_HaveBz_ZhList nil)
      (foreach L_Temp L_DrawZhList
	(if (/= (cadr L_Temp) "")
	  (setq Lg_HaveBz_ZhList (cons L_Temp Lg_HaveBz_ZhList))
	)
      )
;;;绘图比例和文字大小
      (setq wg_sca	       (DL_GetDrawingFactor)
            wg_txtoffset (/ 1 wg_sca) 
	    wg_txth	       (/ (Dl_GetTextHeight) wg_sca)
	    wg_soft_path       (HY_GetInstallDir)
	    wg_user_path       (DL_GetUserSettingsDir)
;;;wg_thickness--结构层厚度
	    wg_care_first      (nth 0 L_htcsList)  ;;是否控制首付桩号
	    wg_first_zh	       (nth 1 L_htcsList)  ;;首付桩号 ;
	    wg_thickness       (nth 2 L_htcsList)  ;;结构层厚度
	    wg_draw_step       (nth 3 L_htcsList)  ;;分图长度
	    L_IsDimSjxZrx      (nth 8 L_htcsList)  ;;是否标注设计线自然线
	    L_IsDrawWg         (nth 9 L_htcsList)  ;;是否绘制网格
	    L_IsDrawSx         (nth 10 L_htcsList)  ;;是否绘制竖线
		wg_off_y           (nth 11 L_htcsList)  ;;标尺与表头的距离
	    L_tkcsb (list (nth 6 L_basecsList) (nth 7 L_basecsList) (nth 8 L_basecsList))
      )
;;;读取表头设置
      (setq w_file        (strcat wg_user_path "\\hyszzdbt.dat")
;;;表头基本参数--w_base_para
	    w_base_para	  nil
	    wg_head_items nil
	    w_value	  nil
;;;表栏参数--wg_head_items
;;;0 10.0 3 P设计坡度与距离                设计坡度与距离
;;;1 15.0 3 B地面设计高程                    地面设计高程
;;;2 15.0 3 A原地面高程                        原地面高程
;;;3 15.0 3 I路中填挖高                        路中填挖高
;;;4 10.0 3 V填挖方                                填挖方
;;;5 10.0 3 E间距                                    间距
;;;6 20.0 3 H桩号                                    桩号
;;;7 10.0 3 C交叉口(编号)                    交叉口(编号)
;;;8 15.0 3 Q平曲线                                平曲线
;;;9 12.0 3 T路面设计高比原地面高     路面设计高比原地面高
;;;10 12.0 3 W路面设计高比原地面低    路面设计高比原地面低
;;;11 12.0 3 K空栏   
;;;12 12.0 3 空栏 空栏
;;;;13 12.0 3 竖曲线 竖曲线
      )
      (if (findfile w_file)
        (setq w_fn (open w_file "r"))
        (progn
          (setq w_file (strcat wg_soft_path hyszdl_gv_user_dir)
                w_file (strcat w_file "\\hyszzdbt.dat")
          )
          (if (findfile w_file)
            (setq w_fn (open w_file "r"))
          )
        )
      )
      (if w_fn
				(progn
				  (setq	w_value	    (read-line w_fn)
					w_base_para (HY_SeparateString w_value)
				  )
				  (while (setq w_value (read-line w_fn))
				    (setq w_item	(HY_SeparateString w_value)
					  wg_head_items	(cons w_item wg_head_items)
				    )
				  )
				  (setq wg_head_items (reverse wg_head_items))
				  (close w_fn)
				)
				(DL_MsgOK "表头设置文件被破坏!")
      )
;;;得到空栏与中桩设计高的高差表      
      (if (= (type wg_head_items) 'list)
      	(progn
      		(setq indexs (mapcar 'car wg_head_items))
      		(if (member "12" indexs)		
      			(progn
				      (setq w_kl_bgstr
					     (getstring
					       "\n输入空栏与中桩设计高的高差(有多个时用逗号隔开)<0.0>:"
					     )
				      )
				      (if (= w_kl_bgstr "")
								(setq w_kl_dbgb (list 0.0))
								(progn
								  (setq w_kl_dbgb (HY_Str2StrLst w_kl_bgstr))
								  (if w_kl_dbgb
								    (setq w_kl_dbgb (mapcar 'atof w_kl_dbgb))
								    (setq w_kl_dbgb (list 0.0))
								  )
								)
				      )
      			)
      		)
      	)
      )
      
  ;;得到地质概况
  ;;(setq w_DZGKList (ZDM_GetDZGKData))  
 
;;;新的Lxf
;;;表头宽度(0)  表头字高(1)  文字对齐(2) 标尺顶高(上部余高)(3) 标尺底高(下部余高)(4)
;;;坡度表示方式(5) 竖曲加密间距(6) 填挖高是否含结构层(7) 标尺总高(8)
      (setq wg_h_wid	      (atof (nth 0 w_base_para));;表头宽度
	    wg_htxt_h	      (atof (nth 1 w_base_para));;表头字高
	    wg_htxt_j	      (atoi (nth 2 w_base_para));;文字对齐
	    wg_rule_uh	      (atof (nth 3 w_base_para));;标尺顶高(上部余高)
	    wg_rule_dh	      (atof (nth 4 w_base_para));;标尺底高(下部余高)
	    wg_slp_mode	      (atoi (nth 5 w_base_para));;坡度表示方式;
	    wg_sqx_step	      (atof (nth 6 w_base_para));;竖曲加密间距-
	    L_twgIsHJgc       (atoi (nth 7 w_base_para));;挖填高是否含结构层
	    wg_rule_ah	      (atof (nth 8 w_base_para));;标尺总高
	    wg_biaotoushuxian (atoi (nth 9 w_base_para));;是否绘制表头竖线 
	    wg_h_hsc	      (nth 4 L_htcsList)        ;;横向比例
	    wg_h_vsc	      (nth 5 L_htcsList)        ;;竖向比例
	    w_base_para	nil
      )
;;;计算标尺的有效标高高差--wg_valid_rule
      (if L_NewRuleHigh
				(progn
				  (setq wg_valid_rule L_NewRuleHigh
					wg_rule_ah (+ wg_valid_rule wg_rule_uh wg_rule_dh)
					L_NewRuleHigh nil
				  )
				)
        (setq wg_valid_rule (- wg_rule_ah wg_rule_uh wg_rule_dh))
      )
;;;计算横向和竖向的放缩系数--wg_xscale--wg_yscale
      (setq wg_xscale (/ 1000.0 wg_h_hsc wg_sca)
	    wg_yscale (/ 1000.0 wg_h_vsc wg_sca)
      )
;;;计算表头基点相对于图框左下角的偏移量--wg_p00_x--wg_p00_y
      (setq w_head_h 0.0)
      (foreach w_head_item wg_head_items
				(setq w_head_h (+ w_head_h (atof (cadr w_head_item))))
      )
      (setq w_head_item nil)
      (setq wg_p00_x (nth 6 L_htcsList)
            wg_p00_y (nth 7 L_htcsList)
            wg_p00_x (/ wg_p00_x wg_sca)
            wg_p00_y (/ wg_p00_y wg_sca))
      (setq
	    wg_p00_x  (+ wg_p00_x (/ wg_h_wid wg_sca));;wg_h_wid表头宽度-
	    wg_p00_y  (+ wg_p00_y (/ w_head_h wg_sca))
;;;基点正方形的边长
	    wg_off_x (/ 10.0 wg_sca)
		wg_off_y (/ wg_off_y wg_sca)
	    w_ll_dist nil
      )
;;;读取北方向
      (setq wg_north_dang (HY_GetNorthDirection))
      
;;;计算最大与最小桩号--w_max_zh--w_min_zh
      (setq L_DrawZhList (mapcar 'car L_DrawZhList));;去掉备注-
      (setq w_min_zh (car L_DrawZhList)
	    w_max_zh (last L_DrawZhList))
      
	   ;;初始化构造物数据
	  ;;(if (/= wg_zddata_file "")
		(ZDM_InitFormationData (list wg_bgz_file wg_bgs_file wg_zddata_file wg_xscale wg_yscale))
	    ;;)
    );;end progn
  );end if
  

  
;;;---------------绘制纵断面---------------------
  (if (and w_min_zh w_max_zh)
    (progn
	;;;考虑首幅图桩号
      (if (and (= wg_care_first 1) (< wg_first_zh w_min_zh))
        (setq wg_first_zh w_min_zh)
      )

;;;begin------------计算分幅桩号列表--w_sep_zhlist
;;;计算每幅图的桩号长度--整数
	  ;;(setq w_sep_zhlen	(/ wg_draw_step wg_sca)
      (setq w_sep_zhlen	wg_draw_step
	    w_sep_zhlen	(* w_sep_zhlen wg_h_hsc)
	    w_sep_zhlen	(fix (/ w_sep_zhlen 1000.0))
      )
;;;最小桩号加入
      (setq w_sep_zhlist (list w_min_zh))
 ;;;考虑首幅图桩号
         (setq w_first_zh wg_first_zh)
         (if (= wg_care_first 1)
   		(if (and (> w_first_zh w_min_zh) (< w_first_zh w_max_zh))
   		  (setq w_sep_zhlist (append w_sep_zhlist (list w_first_zh)))
   		)
         )
;;;中间分图桩号加入
    (if (and (= wg_care_first 1) (>= w_first_zh w_max_zh))
      (princ)
      (progn
	      (setq w_first_zh (+ (last w_sep_zhlist) w_sep_zhlen))
	      (while (< w_first_zh w_max_zh)
	                (setq w_str_zh (rtos w_first_zh 2 2))
	                (setq w_first_zh (atoi w_str_zh))
			(setq w_sep_zhlist (append w_sep_zhlist (list w_first_zh)))
			(setq w_first_zh (+ w_first_zh w_sep_zhlen))
	      )
      )
    )

;;;最大桩号加入
      (setq w_sep_zhlist (append w_sep_zhlist (list w_max_zh)))
;;;end------------计算分幅桩号列表--
;;;生成要标注的桩号列表--------------------------begin
      (setq wg_dim_zhlist w_sep_zhlist)
     ;;把L_DrawZhList加入--(最大最小桩号已经加入不要再次加入)--
      (setq L_DrawZhList (cdr L_DrawZhList)     ;;去掉最小桩号--
	    L_DrawZhList (reverse L_DrawZhList)
	    L_DrawZhList (cdr L_DrawZhList)     ;;去掉最大桩号--
      )
      (setq wg_dim_zhlist (append wg_dim_zhlist L_DrawZhList)
	    L_DrawZhList nil)
;;;排序
 (setq wg_dim_zhlist (HY_RealSort wg_dim_zhlist))
 (zh_get_dimcfg)
 ;;如果两个桩号在1的范围内非常接近，将整桩从桩号列表中删除
 ;;算法：对排序后的桩号列表，第i个和i+1个桩号进行比较，
 ;;如果在1的范围内相等，则将非整桩加入临时tempZhList列表
 ;;否则，将第i个桩号加入tempZhList列表
 ;;将tempZhList排序，wg_dim_zhlist的值赋为tempZhList
;;; (setq tempZhList nil)
;;; (setq tempzh1 (car wg_dim_zhlist))
;;; (setq tempZh (cdr wg_dim_zhlist))
;;; (while (/= tempZh nil)
;;;     (if (equal tempzh1 (car tempzh) wg_txth)
;;;        (progn
;;;          (if (not (equal (rem tempzh1 w::stk_intvl)  0.0  0.01))
;;;              (setq tempZhList (cons tempzh1 tempZhList))    ;;破桩加入
;;;          )
;;;          (if (not (equal (rem (car tempzh) w::stk_intvl)  0.0  0.01))
;;;              (setq tempZhList (cons (car tempzh) tempZhList));;破桩加入
;;;          )
;;;          (if (and (equal (rem tempzh1 w::stk_intvl)  0.0  0.01) (equal (rem (car tempzh) w::stk_intvl)  0.0  0.01))
;;;              (setq tempZhList (cons (car tempzh) tempZhList))  ;;同为整桩，任一桩加入
;;;          )
;;;          (setq tempzh1 (cadr tempzh))
;;;          (setq tempZh (cdr tempZh))
;;;        )
;;;        (progn
;;;           (setq tempZhList (cons tempzh1 tempZhList))
;;;           (setq tempzh1 (car tempzh))
;;;        )
;;;     )
;;;     (setq tempZh (cdr tempZh))
;;; )
;;; (setq tempZhList (cons (last wg_dim_zhlist) tempZhList))
;;; (setq wg_dim_zhlist (HY_RealSort tempZhList))

;;(princ "\n加密后：wg_dim_zhlist＝")(princ wg_dim_zhlist)(getpoint "加密后")
;;;生成要标注的桩号列表--------------------------end--
      
;;;计算设计标高--((桩号 标高 矫正值) ...)
			
      (setq wg_dim_bglist
     
	     (arx_calsjbg
	       (cons wg_bgs_file wg_dim_zhlist)
	     )
	     
      )
      (setq wg_dim_zhlist (hy_realsort wg_dim_zhlist))

;;;计算自然标高--((桩号 标高1 标高2) ...)
      (setq wg_dim_zrbglist
	     (arx_calzrbg (cons wg_bgz_file wg_dim_zhlist))
      )
;;;初始化A循环的有关变量
      (setq w_counter 1
	    w_all_count	 (length w_sep_zhlist);;w_sep_zhlist分幅桩号列表--
;;;某幅图的桩号子表--w_ch_zhlist
	    w_ch_zhlist	     nil
;;;某幅图的标高子表--w_ch_bglist
	    w_ch_bglist	     nil
;;;某幅图的自然标高子表--w_ch_zrbglist
	    w_ch_zrbglist     nil
;;;上一幅图的结束桩号
	    w_pre_zh	     nil
;;;上一幅图的结束标高
	    w_pre_bg	     nil
;;;上一幅图的结束自然标高
	    w_pre_zrbg	     nil
      )

	;;lxf 2003.3.12 start
	(while (< (car wg_dim_zhlist) (car w_sep_zhlist))
		(setq wg_dim_zhlist (cdr wg_dim_zhlist))
	)
	;;lxf 2003.3.12 end
;;;begin_A----------------------进入循环,分幅绘制纵断面

      (princ "\n正在工作,请稍候......")
 (while (< w_counter w_all_count)
	;;(getpoint "eee")
;;;提取该幅图的起终点桩号
	(setq wg_ffzh (nth (- w_counter 1) w_sep_zhlist)
	      wg_bbzh (nth w_counter w_sep_zhlist)
	)
    (setq ffzhtxt (Dl_StakeToDimStr wg_ffzh wg_ffzh))
    (setq bbzhtxt (Dl_StakeToDimStr wg_bbzh wg_bbzh))
    ;;;L_tkcsb - 没有考虑出图比例的图框长宽
    
    (setq L_ptInnerLL (DL_DrawTk wg_basp (nth 0 L_tkcsb) (nth 1 L_tkcsb) (nth 2 L_tkcsb) (- w_all_count 1) w_counter (strcat wg_road_name " (" ffzhtxt "~" bbzhtxt ")")))
    ;;;--------------------------------------------
;;;计算四个基点
;;;wg_head_bp    表头基点
;;;wg_items_bp   栏基点
;;;wg_rule_bp    标尺基点
;;;wg_net_bp    网格基点
	(setq wg_head_bp  (list	(+ (car L_ptInnerLL) wg_p00_x)
				(+ (cadr L_ptInnerLL) wg_p00_y)
				0.0
			  )
	      wg_items_bp (list	(+ (car wg_head_bp) wg_off_x)
				(cadr wg_head_bp)
				0.0
			  )
	      wg_rule_bp  (list	(car wg_head_bp)
				(+ (cadr wg_head_bp) wg_off_y)
				0.0
			  )
	      wg_net_bp	  (list (car wg_items_bp) (cadr wg_rule_bp) 0.0)
	)
;;;绘制表头---------调用子函数,引用全局变量
	(setvar "clayer" wg_btbc_layer)
	(hy_sv)
	(hyzdm_insert_zdbt wg_head_bp (/ 1 wg_sca) (/ 1 wg_sca))
	;;绘制横竖向比例
	(ZDM_DrawScale wg_rule_bp wg_h_wid (/ 1 wg_sca) wg_h_hsc wg_h_vsc)
	(hy_rv)
;;;提取本幅图的桩号子表、标高子表和自然标高子表
;;;初始化本幅图的桩号子表、标高子表和自然标高子表
;;;如果有上一幅图的结束桩号等--直接初始化
;;;否则,从父表中取第一项并且刷新父表从第二项开始
	(if (and w_pre_zh w_pre_zrbg w_pre_bg)
	  (setq	w_ch_zhlist   (list w_pre_zh)
		w_ch_bglist   (list w_pre_bg)
		w_ch_zrbglist (list w_pre_zrbg)
	  )
	  (setq
		w_ch_zhlist	nil
		w_ch_bglist	nil
		w_ch_zrbglist	nil
	  )
	)
;;;提取桩号位于该幅图的起终点桩号之间的桩号、标高和自然标高加入子表
	(while (<  (caar wg_dim_bglist) (car wg_dim_zhlist))
		(setq wg_dim_bglist (cdr wg_dim_bglist))
	)
	(while (< (caar wg_dim_zrbglist) (car wg_dim_zhlist))
		(setq wg_dim_zrbglist (cdr wg_dim_zrbglist))
	)
	(setq w_flag t)
	(while (and w_flag wg_dim_zhlist)
	  (setq w_zh (car wg_dim_zhlist))

	  (if (and (>= w_zh wg_ffzh) (<= w_zh wg_bbzh))
	  	(progn
	  		(setq w_ch_zhlist	  (append w_ch_zhlist (list w_zh)))
	  		(setq w_ch_bglist	  (append w_ch_bglist (list (car wg_dim_bglist))))
	  		(setq w_ch_zrbglist	  (append w_ch_zrbglist (list (car wg_dim_zrbglist))))			  
			  (setq wg_dim_zhlist	  (cdr wg_dim_zhlist)
			  			wg_dim_bglist	  (cdr wg_dim_bglist)
			  			wg_dim_zrbglist (cdr wg_dim_zrbglist)
		    )
	  	)
	    
	    (setq w_flag nil)
	  )
	)
;;;begin_B-------------分段绘制本幅图
	(setq w_this_zhlist   nil
	      w_this_bglist   nil
	      w_this_zrbglist nil
	      w_pre_zh	      (last w_ch_zhlist)
	      w_pre_bg	      (last w_ch_bglist)
	      w_pre_zrbg      (last w_ch_zrbglist)
	      w_pre_thiszh    nil
	      w_pre_thisbg    nil
	      w_pre_thiszrbg  nil
	      L_bgcvalide_Flag t;;nil同一桩号的设计标高和自然标高差大于标尺的有效范围-
	      			;;t ...高差在有效范围内-
	)
;;;提取本段的桩号子表、标高子表和自然标高子表--直到父表取空为止
	(while (and L_bgcvalide_Flag   w_ch_zhlist)
		(setq w_kl_dbgb_Temp w_kl_dbgb);;;lxf add 2003/6/5
	  (&wait_bz)

;;;初始化本段的桩号子表、标高子表和自然标高子表
;;;如果有上段的结束桩号等--直接初始化
;;;否则,从父表中取第一项并且刷新父表从第二项开始
	  (if (and w_pre_thiszh w_pre_thisbg w_pre_thiszrbg)
	    (setq w_this_zhlist	  (list w_pre_thiszh)
		  w_this_bglist	  (list w_pre_thisbg)
		  w_this_zrbglist (list w_pre_thiszrbg)
	    )
	    (setq w_this_zhlist	  (list (car w_ch_zhlist))
		  w_this_bglist	  (list (car w_ch_bglist))
		  w_this_zrbglist (list (car w_ch_zrbglist))
		  w_ch_zhlist	  (cdr w_ch_zhlist)
		  w_ch_bglist	  (cdr w_ch_bglist)
		  w_ch_zrbglist	  (cdr w_ch_zrbglist)
	    )
	  )
;;;提取本幅图的分段子表
;;;初始标高设定为第一桩的标高
;;;初始化正负高差为0.0
	  (setq	w_flag	   t
					w_init_bg  (cadr (car w_this_bglist));;w_this_bglist设计标高-
					w_max_bg   w_init_bg
					w_min_bg   w_init_bg                 ;;w_min_bg 本段的最小桩号(用于计算标尺基点标高)--
					w_pgc	   0.0                       ;;;正高差
					w_ngc	   0.0                       ;;;负高差
					w_is_maxbg 0
					w_is_minbg 0
					L_is_maxbg_Zr 0
					L_is_minbg_Zr 0
	  )
	  (while (and w_flag w_ch_zhlist)                        ;;w_ch_zhlist本幅桩号列表--
	    (&wait_bz)
	    (setq w_bg	(cadr (car w_ch_bglist))                 ;;设计标高-
		  w_jbg	(caddr (car w_ch_bglist))                ;;校正值-
		  L_ZrbgFirst (cadr (car w_ch_zrbglist))         ;;第一标高-- 
		  L_ZrbgSecond (caddr (car w_ch_zrbglist))       ;;第二标高--
	    )
	    (if	w_jbg
	      (setq w_bg (+ w_bg w_jbg))
	    )
;;;计算后续标高与初始标高的高差
	    (if	(> (- w_bg w_init_bg) w_pgc)            ;;w_pgc正高差-
	      (setq w_pgc      (- w_bg w_init_bg)
		    w_is_maxbg 1
	      )
	    )
	    (if	(< (- w_bg w_init_bg) w_ngc)            ;;w_ngc负高差-
	      (setq w_ngc      (- w_bg w_init_bg)
		    w_is_minbg 1
	      )
	    )
	    (if L_ZrbgFirst
		    (if (> (- L_ZrbgFirst w_init_bg) w_pgc)
		      (setq w_pgc  (- L_ZrbgFirst w_init_bg)
			    L_is_maxbg_Zr 1
		      )
		    )
		    (if (< (- L_ZrbgFirst w_init_bg) w_ngc)
		      (setq w_ngc (- L_ZrbgFirst w_init_bg)
			    L_is_minbg_Zr 1
		      )
		    )
	    )
	    ;;暂时不考虑第二标高--
;;;如果碰到正高差减去负高差大于标尺的有效高度停止提取,否则提取的值加入子表

	    (if	(> (- w_pgc w_ngc) wg_valid_rule)
	      (setq w_flag nil);;停止提取--
	      (progn
		(if (= w_is_minbg 1)
		  (setq	w_min_bg w_bg
			w_is_minbg 0
		  )
		)
		(if (= w_is_maxbg 1)
		  (setq	w_max_bg w_bg
			w_is_maxbg 0
		  )
		)
		(if (= L_is_minbg_Zr 1)
		  (setq w_min_bg L_ZrbgFirst
			L_is_minbg_Zr 0
		  )
		)
		(if (= L_is_maxbg_Zr 1)
		  (setq w_max_bg L_zrbgfirst
			L_is_maxbg_Zr 0
		  )
		)
		(setq w_this_zhlist   (append w_this_zhlist
					      (list (car w_ch_zhlist))
				      )
		      w_this_bglist   (append w_this_bglist
					      (list (car w_ch_bglist))
				      )
		      w_this_zrbglist (append w_this_zrbglist
					      (list (car w_ch_zrbglist))
				      )
		      w_ch_zhlist     (cdr w_ch_zhlist)
		      w_ch_bglist     (cdr w_ch_bglist)
		      w_ch_zrbglist   (cdr w_ch_zrbglist)
		)
	      )
	    )
	  )
;;;计算标尺基点标高--wg_rule_bg0
;;;记录该段子表的最后一项作为下一段子表的第一项 w_ch_zrbglist w_ch_bglist
(setq w_min_bg 99999)
(foreach sub_bg w_this_bglist
	;;(setq w_min_bg (min w_min_bg (+ (nth 1 sub_bg) (nth 2 sub_bg))))
	(setq w_min_bg (min w_min_bg (nth 1 sub_bg)))
) 
(foreach sub_bg w_this_zrbglist
	(setq w_min_bg (min w_min_bg (nth 1 sub_bg)))
) 

	  (setq	w_pre_thiszh   (last w_this_zhlist)
		w_pre_thisbg   (last w_this_bglist)
		w_pre_thiszrbg (last w_this_zrbglist)
		wg_rule_bg0    (fix (- w_min_bg wg_rule_dh));;wg_rule_dh下部余高-
		w_zh_range     (- (last w_this_zhlist) (car w_this_zhlist))
	  )
;;;(princ "\n桩号列表＝")(princ w_this_zhlist)(princ "\n网格长度：")(princ w_zh_range)(getpoint "\ndebug2\n")
	  (if (< w_zh_range 0.1);;L_bgcvalide_Flag
	       (setq L_bgcvalide_Flag nil)
	       (progn
		      ;;;绘制标尺---------调用子函数,引用全局变量
		  (setvar "clayer" wg_btbc_layer)
		  (hy_sv)
	 	  (hyzdm_draw_rule wg_rule_bp)
		  (hy_rv)
	;;;绘制网格---------调用子函数,引用全局变量
		  (if (= L_IsDrawWg 1)
		    (progn
			  (setvar "clayer" wg_wg_layer)
		      (hy_sv)
			  (hyzdm_draw_net wg_net_bp w_zh_range)
		      (hy_rv)
		      )
	          );;(getpoint "debug3\n")
	;;;根据w_this_zhlist界定的桩号范围绘制设计路面线
		  (setq	w_section_szh (car w_this_zhlist)
			w_section_ezh (last w_this_zhlist)
		  )
		  (setvar "clayer" wg_sjx_layer)
	;;;绘制设计线

	    (setq sjxent (hyzdm_draw_sjx
		    w_section_szh
		    w_section_ezh
		    wg_net_bp
		    wg_rule_bg0
	    ))

	  ;;;标注:桩号\高程\备注--;lxf
	    (setvar "clayer" wg_sjg_zd)
	    (hyzdm_Dim_zh_bg_bz
		    w_section_szh
		    w_section_ezh
		    wg_net_bp
		    wg_rule_bg0)

	 ;;标注设计线坡度-
	      (hyzdm_Dim_SjxPD
		    w_section_szh
		    w_section_ezh
		    wg_net_bp
		    wg_rule_bg0)

	 ;;;标注竖曲线
	          (setvar "clayer" wg_sqxdim_layer)
		  (hyzdm_dim_sjx
		    w_section_szh
		    w_section_ezh
		    wg_net_bp
		    wg_rule_bg0
		  )
	;;;根据w_this_zhlist界定的桩号范围绘制自然路面线
		  (setvar "clayer" wg_zrx_layer)
		  (hy_sv)
		  (setq zrxent (hyzdm_draw_zrx
		    wg_net_bp       ;;网格左下角基点
		    wg_rule_bg0     ;;网格左下角基点代表的高程
		    w_section_szh   ;;开始桩号
		    w_section_ezh   ;;结束桩号
		    w_this_zrbglist ;;本段自然标高表
		  ))
		  (hy_rv)
	;;;标注设计线，自然线
	(if (= L_IsDimSjxZrx 1)
		(ZDM_DimZrxSjx (list zrxent sjxent)) 
	) 
	;;;根据w_this_zhlist界定的桩号范围绘制桥涵构造物
	;;里面包含了实现绘制道路起终点接路的功能
	(if (/= wg_zddata_file "")
		  (ZDM_DrawFormation(list wg_net_bp w_section_szh w_section_ezh wg_rule_bg0 wg_rule_ah))
	)
	;;;根据w_this_zhlist界定的桩号范围填写表栏
	;;;初始化表栏基点
		  ;;(setvar "clayer" wg_bldim_layer)
		  (setvar "clayer" wg_Textdim_layer)
		  (command ^ "_.line"
			   wg_items_bp
			   (polar wg_items_bp 0 (* wg_xscale w_zh_range))
			   ""
		  )
		  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
		  (setq w_item_basp wg_items_bp)
	;;;对表栏参数表做循环
		  (foreach w_head_item wg_head_items ;; w_item_0bq
		    (hy_sv)
		    (&wait_bz)
		    (setq w_index     (atoi (nth 0 w_head_item))
			  w_item_wid  (atof (nth 1 w_head_item))
			  w_item_prec (atoi (nth 2 w_head_item))
		    )
		    (if (= (length w_head_item) 6)
		    	(setq w_item_0bq (atoi (nth 5 w_head_item)))
		    	(setq w_item_0bq 0)
		  	)

	;;;rwqrwq
	        (if (equal w_section_szh w_section_ezh 0.001)
	          (setq w_section_ezh (+ w_section_szh 0.001))
	        )
		    (cond
		      ((and (not (equal w_section_szh w_section_ezh 0.001)) (= w_index 0))
	;;;索引号为 0, 填写坡度距离
		       (setq w_item_basp
			      (hyzdm_pdjl_row
								w_item_basp
								w_item_wid
								w_item_prec
								w_item_0bq
								w_section_szh
								w_section_ezh
								w_this_bglist
			      )
		       )
		      )
		      ((or (= w_index 1) (= w_index 14))
	;;;;;;索引号为 1, 填写设计中高
		       (setq w_item_basp 
			      (hyzdm_sjbg_row           
			                                w_index
							w_item_basp
							w_item_wid
							w_item_prec
							w_item_0bq
							w_section_szh
							w_section_ezh
							w_this_bglist
			      )
		       )
		      )
		      ((= w_index 2)
	;;;;;;索引号为 2, 填写自然中高
		       (setq w_item_basp
			      (hyzdm_zrbg_row  
								w_item_basp
								w_item_wid
								w_item_prec
								w_item_0bq
								w_section_szh
								w_section_ezh
								w_this_zrbglist
			      )
		       )
		      )
		      ((= w_index 3)
	;;;;;;索引号为 3, 填写填挖高
		       (setq w_item_basp
			      (hyzdm_twg_row
							w_item_basp	   w_item_wid
							w_item_prec	   w_item_0bq
							w_section_szh	  w_section_ezh	   
							w_this_zrbglist w_this_bglist
			       )
		       )
		      )
		      ((= w_index 4)
	;;;;;;索引号为 4, 填写填挖方
		       (setq w_item_basp
			      (hyzdm_twf_row
								w_item_basp
								w_item_wid
								w_item_prec
								w_section_szh
								w_section_ezh
			      )
		       )
		      )
		      ((= w_index 5)
	;;;;;;索引号为 5, 填写间距
		       (setq w_item_basp
			      (hyzdm_jj_row
								w_item_basp
								w_item_wid
								w_item_prec
								w_item_0bq
								w_this_zhlist
			      )
		       )
		      )
		      ((= w_index 6)
	;;;;;;索引号为 6, 填写桩号栏
		       (setq w_item_basp
			      (hyzdm_zh_row
					w_item_basp
					w_item_wid
					w_item_prec
					w_this_zhlist
			      )
		       )
		      )
		      ((= w_index 7)
	;;;;;;索引号为 7, 填写交叉口栏
		       (setq w_item_basp
			      (hyzdm_jck_row
								w_item_basp
								w_item_wid
								w_item_prec
								w_section_szh
								w_section_ezh
			      )
		       )
		      )
		      ((= w_index 8)
	;;;;;;索引号为 8, 填写平曲线栏
		       (setq w_item_basp
		              (ZDM_QLT w_item_basp wg_xscale w_item_wid w_item_prec w_item_0bq w_section_szh w_section_ezh wg_jd_file)
;;任蔚青修改2004-12-30，zdm_qlt在pm_line中导出
		       )
		      )
		      ((= w_index 9)
	        ;;;;;;索引号为 9, 填写设计路面比原地面高
		       (setq w_item_basp
			      (hyzdm_ubg_row
							w_item_basp
							w_item_wid
							w_item_prec
							w_item_0bq
							w_section_szh
							w_section_ezh
							w_this_zrbglist
							w_this_bglist
			      )
		       )
		      )
		      ((= w_index 10)
	;;;;;;索引号为 10, 填写设计路面比原地面低
		       (setq w_item_basp
			      (hyzdm_dbg_row
				w_item_basp
				w_item_wid
				w_item_prec
				w_item_0bq
				w_section_szh
				w_section_ezh
				w_this_zrbglist
				w_this_bglist
			      )
		       )
		      )
		      ;;;add by wzy 2003-3-28 16:02
		      ((= w_index 11)
	;;;;;;索引号为 11, 填写超高图 
			
		       (setq w_item_basp
			      (hyzdm_cgt_row
						w_item_basp
						w_item_wid
						w_item_prec
						w_item_0bq
						w_section_szh
						w_section_ezh
			      )
		       )
		      )
		      ;;;end of add by wzy 2003-3-28 16:02
	;;;;;;索引号为 12,填写空栏,		 
		      ((= w_index 12)
		       (if w_kl_dbgb_Temp
						 (setq w_kl_dbg (car w_kl_dbgb_Temp)
						       w_kl_dbgb_Temp (cdr w_kl_dbgb_Temp)
						 )
						 (if (null w_kl_dbg) (setq w_kl_dbg 0.0))
	       )
		       (setq w_item_basp  
		                         (hyzdm_kl_row
						   w_item_basp
						   w_item_wid
						   w_item_prec
						   w_item_0bq
						   w_section_szh
						   w_section_ezh
						   w_kl_dbg
						   w_this_bglist
					 )
		       )
		      )
		      ((= w_index 13)
	;;;;;;索引号为 13, 竖曲线
		       (setq w_item_basp
			      (hyzdm_sqx_row
							w_item_basp
							w_item_wid
							w_item_prec
							w_item_0bq
							w_section_szh
							w_section_ezh
							w_this_bglist
			      )
		       )
		      )
		      ((= w_index 15)
	;;;;;;索引号为 15, 地质概况
		       (setq w_item_basp
			      (ZDM_DrawDZGK
							w_item_basp
							w_item_wid
							wg_sca
							wg_xscale
							wg_htxt_h
							w_section_szh
							w_section_ezh
							;;w_DZGKList
			      )
		       )
		      )
		    )
		    (hy_rv)
		  )
		 ;;;根据w_this_zhlist界定的桩号范围更新标尺基点,网格基点,分栏基点
		  (setq	wg_rule_bp  (polar
				      wg_rule_bp
				      0
				      (+ (* w_zh_range wg_xscale) (* 2.0 wg_off_x))
				    )
			wg_net_bp   (polar wg_rule_bp 0 wg_off_x)
			wg_items_bp (polar wg_net_bp (* 1.5 pi) wg_off_y)
		  )
	      );;progn
	  );end if
	)
;;;end_B-------------分段绘制本幅图
       (hy_sv)
;;;A循环的循环变量增一
	(setq w_counter (1+ w_counter))
;;;记录图框基点
	(setq w_tkptb (cons wg_basp w_tkptb))
;;;更新图框基点
	;;;(setq	  wg_basp   (polar wg_basp (* 0.5 pi) (+ (/ 841.0 wg_sca) 200.0)))
	(setq	 wg_basp  (polar wg_basp (* 0.5 pi) (/ ( + 50 (nth 2 L_tkcsb)) wg_sca) ))
    )
;;;end_A----------------------进入循环,分幅绘制纵断面-
      (zh_nil_dimcfg)
      (princ "\n......................OK!")
    )
  )
;;;  (#ppuas "zdmdsgn")
  (arxunload "pm_line")
  (pub_re_var)
  (princ)
)

;;;--------------子函数--绘制设计路面线-------------
;;;直接调用的外部变量
;;;wg_sjbg_list,wg_xscale,wg_yscale,wg_sca,wg_bgs_file,wg_sjx_layer
(defun hyzdm_draw_sjx (xc_szh	   xc_ezh      xc_basp	   xc_bash
		       /	   w_kzh_list  w_offd	   w_pi05
		       w_sjbg	   w_sqx_szh   w_sqx_ezh   w_the_zh
		       w_kzh	   w_bg_list   w_kp_list   w_bg
		       w_offx	   w_real_bg   w_correct_bg
		       w_offy	   w_kp	       w_old_plwid
                        sjxent
		      )

;;;整理关键点桩号表w_kzh_list
  (setq	w_kzh_list (list xc_szh xc_ezh)
	w_offd	   2.0
	w_pi05	   (* pi 0.5)
  )
;;(princ (list "\n wg_sjbg_list" wg_sjbg_list))
  (foreach w_sjbg wg_sjbg_list
    (if	(= (nth 2 w_sjbg) 1);;竖曲线的半径是否存在
      (progn
;;;如果该点有竖曲线--按照两米的精度取点
	(setq w_sqx_szh	(nth 13 w_sjbg)
	      w_sqx_ezh	(nth 14 w_sjbg)
	      w_the_zh	(nth 4 w_sjbg)
	)
	(if (and (> w_sqx_szh xc_szh) (< w_sqx_szh xc_ezh))
	  (setq w_kzh_list (cons w_sqx_szh w_kzh_list))
	)
	(if (and (> w_sqx_ezh xc_szh) (< w_sqx_ezh xc_ezh))
	  (setq w_kzh_list (cons w_sqx_ezh w_kzh_list))
	)
	(if (and (> w_the_zh xc_szh) (< w_the_zh xc_ezh))
	  (setq w_kzh_list (cons w_the_zh w_kzh_list))
	)
	(setq w_kzh (- w_the_zh w_offd))
	(while (> w_kzh w_sqx_szh)
	  (if (and (> w_kzh xc_szh) (< w_kzh xc_ezh))
	    (setq w_kzh_list (cons w_kzh w_kzh_list))
	  )
	  (setq w_kzh (- w_kzh w_offd))
	)
	(setq w_kzh (+ w_the_zh w_offd))
	(while (< w_kzh w_sqx_ezh)
	  (if (and (> w_kzh xc_szh) (< w_kzh xc_ezh))
	    (setq w_kzh_list (cons w_kzh w_kzh_list))
	  )
	  (setq w_kzh (+ w_kzh w_offd))
	)
      )
      (progn
;;;否则--只把设计标高折点加入
	(setq w_the_zh (nth 4 w_sjbg))
	(if (and (> w_the_zh xc_szh) (< w_the_zh xc_ezh))
	  (setq w_kzh_list (cons w_the_zh w_kzh_list))
	)
      )
    )
  )
  (setq w_kzh_list (HY_RealSort w_kzh_list))
  (setq w_bg_list (arx_calsjbg (cons wg_bgs_file w_kzh_list)))
;;;求设计线关键点表
  (setq w_kp_list nil)
  (foreach w_bg	w_bg_list
    (setq w_offx (- (car w_bg) xc_szh)
	  w_offx (* w_offx wg_xscale)
    )
    (setq w_real_bg    (cadr w_bg);;标高
	  w_correct_bg (caddr w_bg);;校正值
    )
    (if	w_correct_bg
      (setq w_real_bg (+ w_real_bg w_correct_bg))
    )
    (setq w_offy (- w_real_bg xc_bash)
	  w_offy (* w_offy wg_yscale)
    )
    (setq w_kp (polar xc_basp 0 w_offx)
	  w_kp (polar w_kp w_pi05 w_offy)
    )
    (setq w_kp_list (cons w_kp w_kp_list))
  )
  (setq w_old_plwid (getvar "plinewid"))
  (setvar "plinewid" (DL_GetLayerLineWidth wg_sjx_layer))
  (if w_kp_list
    (progn
      (command ^ "_.pline")
      (foreach w_kp w_kp_list
	(command w_kp)
      )
      (command "")
    )
  )
  (setvar "plinewid" w_old_plwid)
  (setq sjxent (entlast))
)

;;;1.函数名:hyzdm_Dim_SjxPD----------;;
;;;2.编写:Lxf 2003.3.3---------------;;
;;;3.功能:标注设计线坡度--;;
(defun hyzdm_Dim_SjxPD (xc_szh	   xc_ezh      xc_basp	   xc_bash
			/ w_kzh_list     w_pi05
		       w_sjbg	   w_the_zh
		       w_kzh	   w_bg_list   w_kp_list   w_bg
		       w_offx	   w_real_bg   
		       w_offy	   w_kp	       w_old_plwid
			L_count   L_index
			L_list    L_listNext
			L_pt     L_ptNext
			L_zh    L_zhNext    L_bg   L_bgNext
			L_PD
			)
	
	   (setq w_kzh_list (list xc_szh xc_ezh)
		w_pi05	   (* pi 0.5)
	  )
	 (foreach w_sjbg wg_sjbg_list
	      (progn
		;;;把设计标高折点加入
		(setq w_the_zh (nth 4 w_sjbg))
		(if (and (> w_the_zh xc_szh) (< w_the_zh xc_ezh))
		  (setq w_kzh_list (cons w_the_zh w_kzh_list))
		)
	      )
	  )
	  (setq w_kzh_list (HY_RealSort w_kzh_list))
	  (setq w_bg_list (arx_calsjbg (cons wg_bgs_file w_kzh_list)))
	;;;求设计线关键点－(此时不考虑校正值)
  	(setq w_kp_list nil)
	  (foreach w_bg	w_bg_list;;w_bg(桩号 标高 校正值)
	    (setq w_offx (- (car w_bg) xc_szh);;桩号
		  w_offx (* w_offx wg_xscale)
	    )
	    (setq w_real_bg    (cadr w_bg));;标高
	    (setq w_offy (- w_real_bg xc_bash)
		  w_offy (* w_offy wg_yscale)
	    )
	    (setq w_kp (polar xc_basp 0 w_offx)
		  w_kp (polar w_kp w_pi05 w_offy)
	    )
	    ;(setq w_kp_list (cons w_kp w_kp_list))
	    (setq w_kp_list (cons (list w_kp (car w_bg) (cadr w_bg)) w_kp_list))
	  )
  (setq w_kp_list (reverse w_kp_list))
  (setq L_count (length w_kp_list)
	L_index 0)

  (while (and (< L_index L_count) (< (1+ L_index) L_count))
    (setq L_list (nth L_index w_kp_list)
	  L_listNext (nth (1+ L_index) w_kp_list)
	  L_pt (car L_list)
	  L_zh (cadr L_list)
	  L_bg (caddr L_list)
	  L_ptNext (car L_listNext)
	  L_zhNext (cadr L_listNext)
	  L_bgNext (caddr L_listNext)
	  L_PD (- L_bgNext L_bg)
	  L_PD (/ L_PD (- L_zhNext L_zh))
	  L_index (1+ L_index)
    )
    (dl_dimpd  L_ptNext L_pt (dl_GetDrawingScale) (abs L_PD) wg_txth wg_slp_mode)
  )

)
;;;1.函数名:hyzdm_Dim_zh_bg_bz----------;;
;;;2.编写:Lxf 2003.2.27---------------;;
;;;3.功能:标注,桩号\高程\备注--;;
;;;4.参数:xc_szh起始桩 xc_ezh结束桩--;;
(defun hyzdm_Dim_zh_bg_bz (xc_szh  xc_ezh  xc_basp  xc_bash
		       /
			 L_DimList;;需要标注的参数列表((桩号 标高 备注)...)
		         w_bg_list
			 L_zhList   L_TempList
			     w_kp   w_pi05
			   w_bg   w_offx   w_offy
			   w_real_bg   w_correct_bg
			   L_BZ     L_Temp2
			   L_pt1    L_pt2   L_pt3  L_pt4   L_pt5
			   L_zh    L_Bg   L_prec;;标注位数--
			 )
  (setq	w_pi05	   (* pi 0.5)
	L_prec   (dl_getdimprec))
  (setq L_DimList (hyzdm_get_dimcsb xc_szh xc_ezh)
	L_zhList  (mapcar 'car L_DimList))

  (setq w_bg_list (arx_calsjbg (cons wg_bgs_file L_zhList)))
  (if (= (length L_zhList) 1)
    (setq w_bg_list (list w_bg_list))
  )
  ;;求标注所需的点表-;;
   (setq  L_TempList nil)
  (foreach w_bg	w_bg_list
    (setq w_offx (- (car w_bg) xc_szh)
	  w_offx (* w_offx wg_xscale)
    )
    (setq w_real_bg    (cadr w_bg);;标高
	  w_correct_bg (caddr w_bg);;校正值
    )
    (if	w_correct_bg
      (setq w_real_bg (+ w_real_bg w_correct_bg))
    )
    (setq w_offy (- w_real_bg xc_bash)
	  w_offy (* w_offy wg_yscale)
    )
    (setq w_kp (polar xc_basp 0 w_offx)
	  w_kp (polar w_kp w_pi05 w_offy)
    )

    (setq L_BZ (cadr (assoc (car w_bg) L_DimList )));备注-

    (setq L_TempList (cons (List (car w_bg) w_real_bg L_BZ w_kp) L_TempList))
  )
  ;;L_TempList的格式((桩号 标高 备注 对应的设计标高上的点)...);wg_sca
  (foreach L_Temp2 L_TempList
    (setq w_offx (* 15 wg_sca)
	  w_offy (* 25 wg_sca)
	  L_zh  (nth 0 L_Temp2)
	  L_Bg  (rtos (nth 1 L_Temp2) 2 L_prec)
	  L_BZ  (nth 2 L_Temp2)
	  L_BZ  (strcat "(" L_BZ ")")
	  L_pt1 (nth 3 L_Temp2)
	  L_pt2 (polar L_pt1 0 w_offx)
	  L_pt2 (polar L_pt2 w_pi05 w_offy)
	  L_pt3 (polar L_pt2 0 (* 8 wg_sca))
	  L_pt4 (polar L_pt2 0 (* 4 wg_sca));L_pt2和L_pt3的中点-
	  L_pt5 (polar L_pt4 (- w_pi05) wg_txth)
    )
    (setq L_zh (Dl_StakeToDimStr L_zh L_zh))
    (command "line" L_pt1 L_pt2 L_pt3 "")
    
    (command ^ "_.text" "j" "TC" L_pt4 wg_txth 0 L_zh);;桩号--
    (setq L_pt4 (polar L_pt4 w_pi05 (* 0.1 wg_txth)))
    (command ^ "_.text" "j" "BC" L_pt4 wg_txth 0 L_Bg);;高程--
    (command ^ "_.text" "j" "TC" L_pt5 wg_txth 0 L_BZ);;备注--
  )
)
;;;1.函数名:hyzdm_get_dimcsb----------;;
;;;2.编写:Lxf 2003.2.27---------------;;
;;;3.功能:把Lg_HaveBz_ZhList中在给定桩号之间的子表返回--;;
;;;4.参数:xc_szh起始桩 xc_ezh结束桩--;;
;;;5.直接调用的全局变量Lg_HaveBz_ZhList--;;
(defun hyzdm_get_dimcsb ( xc_szh xc_ezh / L_TempList L_retList L_zh)
  (setq L_retList nil)
  (foreach L_TempList Lg_HaveBz_ZhList
    (setq L_zh (car L_TempList))
    (if (and (>= L_zh xc_szh) (<= L_zh xc_ezh))
      (setq L_retList (cons L_TempList L_retList))
    ) 
  )
  L_retList
)
;;;-------------------子函数--标注竖曲线-------------------
;;;竖曲线基点在同一水平线上--标尺最高点 + 一米高度
;;;直接调用的外部变量
;;;wg_sjbg_list,wg_xscale,wg_yscale,wg_sca,wg_rule_ah,wg_txth,wg_soft_path
(defun hyzdm_dim_sjx (xc_szh	  xc_ezh      xc_basp	  xc_bash
		      /		  w_short_l   w_long_l	  w_sjbg
		      w_sqx_szh	  w_sqx_ezh   w_the_zh	  w_sqx_r
		      w_sqx_e	  w_sqx_t     w_sqx_dp	  w_the_bg
		      w_sqx_rstr  w_sqx_estr  w_sqx_tstr  w_sqx_str
		      w_zh_str	  w_offx      w_offy	  w_locp
		      w_l_offx	  w_l_offy    w_r_offx    w_lp	  w_rp
		      w_llp	  w_rrp	      w_mp	  w_txtp
		      w_ltxtp	  w_rtxtp     w_zh_dimb	  w_bg_str
		      w_pre_zh	  w_pre_bg    w_succ_zh	  w_succ_bg
		      w_the_crctbg	      w_sbg	  w_ebg
		      w_zd_p	  w_sp	      w_ep	  w_blkn
		      w_endp xc_s xc_e pts	nPrec     
		      IsBPDZh ;;; t表示 w_the_zh 是变坡点桩号 此处的竖曲线在本幅图中的部分>=1/2
		              ;;; nil 表示w_the_zh不是变坡点桩号,也就是此处的竖曲线在本幅图中的部分<1/2
		     )
;;;;;计算标尺基点标高--xc_bash		
;;;整理关键点桩号表w_kzh_list
  (setq	w_short_l (/ 3.0 wg_sca)
	w_long_l  (/ 20.0 wg_sca)
  )
  (setq nPrec (DL_GetDimPrec))
(defun mend2pt (spt ept xc_s xc_e / x y  pt pt1 pt2 pt3 pt4)
	(if(> (car spt) (car ept))
		(progn
			(setq pt spt)
			(setq spt ept)
			(setq ept pt)
		)
	)
	(if (or (< (car ept) xc_s) (> (car spt) xc_e))
		nil
		(progn
			(if (< (car spt) xc_s)
				(progn
					(setq pt1 (list xc_s -20 0))
					(setq pt2 (list xc_s 20 0))
					(setq spt (inters spt ept pt1 pt2 nil))
				)
			)
			(if (> (car ept)  xc_e)
				(progn
					(setq pt1 (list xc_e -20 0))
					(setq pt2 (list xc_e 20 0))
					(setq ept (inters spt ept pt1 pt2 nil))
				)
			)
			(list spt ept)
		)
	)
	
)
;;
;;0  1--前一变坡点存在
;;1  1--后一变坡点存在       
;;2  1--竖曲线半径存在
;;3  1--变坡点的索引号
;;4  该变坡点的桩号
;;5  该变坡点的标高
;;6  该变坡点的竖曲线半径 R
;;7  前一变坡点的桩号
;;8  前一变坡点的标高
;;9  后一变坡点的桩号
;;10  后一变坡点的标高
;;11  竖曲线元素 E
;;12  竖曲线元素 T
;;13  竖曲线起点桩号***
;;14  竖曲线终点桩号***
;;15  该变坡点的坡差  
  (foreach w_sjbg wg_sjbg_list
    (if	(= (nth 2 w_sjbg) 1)
      (progn      	
;;;如果该点有竖曲线--按照两米的精度取点
				(setq w_sqx_szh	(nth 13 w_sjbg);;;!!!;;13  竖曲线起点桩号***
				      w_sqx_ezh	(nth 14 w_sjbg);;14  竖曲线终点桩号***
				      w_the_zh	(nth 4 w_sjbg);;;!!!;;4  该变坡点的桩号
				)
				;;(princ (list "\nw_sqx_szh::"w_sqx_szh "xc_szh" xc_szh "w_sqx_ezh:"w_sqx_ezh "xc_ezh" xc_ezh "w_the_zh" w_the_zh))
				(if (or(and (> w_sqx_szh xc_szh) (< w_sqx_szh xc_ezh))
				   		(and (> w_sqx_ezh xc_szh) (< w_sqx_ezh xc_ezh))
				   		(and (> w_the_zh xc_szh) (< w_the_zh xc_ezh))
				   		(and (> xc_szh w_sqx_szh)(< xc_ezh w_the_zh))
						)
				  (progn
				    (setq 			  w_sqx_r    (nth 6 w_sjbg);;竖曲线半径
								  w_sqx_e    (nth 11 w_sjbg);;竖曲线元素 E
								  w_sqx_t    (nth 12 w_sjbg);;12  竖曲线元素 T
								  w_sqx_dp   (nth 15 w_sjbg);;15  该变坡点的坡差  
								  w_the_bg   (nth 5 w_sjbg);;5  该变坡点的标高
								  w_pre_zh   (nth 7 w_sjbg);;;!!!;;7  前一变坡点的桩号
								  w_pre_bg   (nth 8 w_sjbg);;8  前一变坡点的标高
								  w_succ_zh  (nth 9 w_sjbg);;9  后一变坡点的桩号
								  w_succ_bg  (nth 10 w_sjbg);;10  后一变坡点的标高
								  w_sqx_rstr (Dl_TrimRight0 (rtos w_sqx_r 2 nPrec))
								  w_sqx_rstr (strcat "R=" w_sqx_rstr)
								  w_sqx_estr (Dl_TrimRight0 (rtos (abs w_sqx_e) 2 nPrec))
								  w_sqx_estr (strcat "E=" w_sqx_estr)
								  w_sqx_tstr (Dl_TrimRight0 (rtos (abs w_sqx_t) 2 nPrec))
								  w_sqx_tstr (strcat "T=" w_sqx_tstr)
								  w_sqx_str  (strcat w_sqx_rstr
							     " "
							     w_sqx_tstr
							     " "
							     w_sqx_estr
						     )
					  w_zh_str   (Dl_TrimRight0 (rtos w_the_zh 2 nPrec))
				    )
				    
				    ;;;;
				   ;;(princ (list "\n xc_ezh" xc_ezh "xc_szh" xc_szh))
				    (setq xc_s (car xc_basp))
				    (setq xc_e (+ xc_s (* (- xc_ezh xc_szh) wg_xscale))) 
				    
				    ;;;;;;;;
				    (setq w_offx (- w_the_zh xc_szh)
						  w_offx (* w_offx wg_xscale)
						)
				    
				    (setq w_sbg	(+ (* w_the_bg (- w_sqx_szh w_pre_zh));;w_the_bg该变坡点的标高
															   (* w_pre_bg (- w_the_zh w_sqx_szh));;;w_pre_bg 前一变坡点的标高
															)
						)
						(if(null (equal w_the_zh w_pre_zh 0.0001))
							(setq w_sbg	(/ w_sbg (- w_the_zh w_pre_zh)))
						)
					  (setq w_ebg	(+ (* w_the_bg (- w_succ_zh w_sqx_ezh))
												   (* w_succ_bg (- w_sqx_ezh w_the_zh))
												)
						)
						(if(null (equal w_succ_zh w_the_zh))
							(setq w_ebg	(/ w_ebg (- w_succ_zh w_the_zh)))
						)
				    
						;;;;;;;;;;
											(setq w_sbg	(+ (* w_the_bg (- w_sqx_szh w_pre_zh));;w_the_bg该变坡点的标高
															   (* w_pre_bg (- w_the_zh w_sqx_szh));;;w_pre_bg 前一变坡点的标高
															)
						)
						(if(null (equal w_the_zh w_pre_zh 0.0001))
							(setq w_sbg	(/ w_sbg (- w_the_zh w_pre_zh)))
						)
					  (setq w_ebg	(+ (* w_the_bg (- w_succ_zh w_sqx_ezh))
												   (* w_succ_bg (- w_sqx_ezh w_the_zh))
												)
						)
						(if(null (equal w_succ_zh w_the_zh))
							(setq w_ebg	(/ w_ebg (- w_succ_zh w_the_zh)))
						)
				    (setq w_offy (- w_the_bg xc_bash)
								  w_offy (* w_offy wg_yscale)
								  w_zd_p (polar xc_basp 0 w_offx)
								  w_zd_p (polar w_zd_p (* 0.5 pi) w_offy)
				    )
				    (setq w_offx (- w_sqx_szh xc_szh)
								  w_offx (* w_offx wg_xscale)
								  w_offy (- w_sbg xc_bash)
								  w_offy (* w_offy wg_yscale)
								  w_sp	 (polar xc_basp 0 w_offx)
								  w_sp	 (polar w_sp (* 0.5 pi) w_offy)
				    )
				    (setq w_offx (- w_sqx_ezh xc_szh)
								  w_offx (* w_offx wg_xscale)
								  w_offy (- w_ebg xc_bash)
								  w_offy (* w_offy wg_yscale)
								  w_ep	 (polar xc_basp 0 w_offx)
								  w_ep	 (polar w_ep (* 0.5 pi) w_offy)
				    )
				    
				    ;;;;;;;;;;;;;
					(setq IsBPDZh t)
				    (if( < w_sqx_szh xc_szh)
				    	(setq w_sqx_szh xc_szh)
				    )
				    (if (< w_the_zh xc_szh)
				    	(setq w_the_zh xc_szh
								IsBPDZh nil)
				    )
				    (if(> w_the_zh xc_ezh)
				    	(setq w_the_zh xc_ezh
								IsBPDZh nil)
				    )
				    (if(> w_sqx_ezh xc_ezh)
				    	(setq w_sqx_ezh xc_ezh)
				    )
					    ;;;;;;;;;;;;
					    
				    (setq w_offx (- w_the_zh xc_szh)
					  w_offx (* w_offx wg_xscale)
					  w_offy (* (+ wg_rule_ah 1) wg_yscale) ;;;wg_rule_ah 标尺总高
					  w_locp (polar xc_basp 0 w_offx)
					  w_locp (polar w_locp (* pi 0.5) w_offy);;边坡点
				    )
				    (setq w_l_offx (- w_the_zh w_sqx_szh));;;竖曲线与边坡点的水平距离
				    (if (< (abs w_l_offx) 0.00001)
				    	(setq w_l_offx 0.001)
				    )
					  (setq w_l_offx (* w_l_offx wg_xscale)
								  w_lp	   (polar w_locp pi w_l_offx)
								 ;; w_rp	   (polar w_locp 0 w_l_offx);;;????
				    )
				    
				    (setq w_l_offy (- w_sqx_ezh w_the_zh ));;;竖曲线与边坡点的水平距离
				    (if (< (abs w_l_offy) 0.00001)
				    	(setq w_l_offy 0.001)
				    )
					  (setq w_l_offy (* w_l_offy wg_xscale)
								  w_rp	   (polar w_locp 0 w_l_offy)
								 ;; w_rp	   (polar w_locp 0 w_l_offx);;;????
				    )
			
				    (setq w_the_crctbg (- w_the_bg w_sqx_e));;;路面标高（记竖曲线）
				    (if	(> w_sqx_dp 0.0);;该变坡点的坡差  
			;;;凸曲线
				      (setq w_llp	 (polar w_lp (* pi 1.5) w_short_l)
					    w_rrp	 (polar w_rp (* pi 1.5) w_short_l)
				      )
			;;;凹曲线
				      (setq w_llp	 (polar w_lp (* pi 0.5) w_short_l)
					    w_rrp	 (polar w_rp (* pi 0.5) w_short_l)
				      )
				    )
				    (setq w_mp (polar w_locp (* pi 1.5) w_long_l))
				    
				    (command ^  "_.line" w_lp w_rp "");;;上端示意线
				    
				    (command ^ "_.line" w_lp w_llp "");;;左示意线
				    (command ^ "_.line" w_rrp w_rp "");;;右示意线
				    
				    
				    ;;(if(and (>  w_the_zh xc_szh) (< w_the_zh xc_ezh))
					(if IsBPDZh
				    	(progn
				    		(command ^ "_.line" w_locp w_mp "");;;中示意线
				    		(setq w_txtp (polar w_locp (* pi 0.5) (/ 0.5 wg_sca)))
				    		(command ^ "_.text" "j" "BC" w_txtp wg_txth 0 w_sqx_str)
						    (setq w_txtp  (midpt w_locp w_mp)
							  w_ltxtp (polar w_txtp pi (/ 0.5 wg_sca))
							  w_rtxtp (polar w_txtp 0 (/ 0.5 wg_sca))
						    )
						    (setq w_zh_str (Dl_StakeToDimStr w_the_zh w_the_zh))
						    (command ^ "_.text"
							     "j"
							     "BC"
							     w_ltxtp
							     wg_txth
							     (rtod (* pi 0.5))
							     w_zh_str
						    )
						    (setq w_bg_str (Dl_TrimRight0 (rtos w_the_bg 2 nPrec)))
						    (command ^ "_.text"
							     "j"
							     "TC"
							     w_rtxtp
							     wg_txth
							     (rtod (* pi 0.5))
							     w_bg_str
						    )
				    	)
				  	)
				  
				    
	
				    
				    
				    ;;(command ^ "_.line" w_sp w_zd_p w_ep "")
				    (setq pts (mend2pt w_sp w_zd_p xc_s xc_e))
				    (if pts
					(progn
				    		(command ^ "_.line" (car pts)  (cadr pts) "")
						(command "_.chprop" (entlast) "" "layer" wg_qx_layer "")
					)
				    )
				    (setq pts (mend2pt w_zd_p w_ep xc_s xc_e))
				    (if pts
				      (progn
				    	(command ^ "_.line" (car pts)  (cadr pts) "")
				    	(command "_.chprop" (entlast) "" "layer" wg_qx_layer "")
				      )
				    )
				    ;;(if(and (>  w_the_zh xc_szh) (< w_the_zh xc_ezh))
					(if IsBPDZh
				    	(progn
				    		    (command ^ "_.circle" w_zd_p (/ 1.0 wg_sca))
						    ;;(command ^ "_.chprop" (entlast) "" "C" 6 "")
						    (setq w_locp (polar w_zd_p (* 0.25 pi) (/ 3.0 wg_sca))
							  			w_endp (polar w_locp 0 (/ 10.0 wg_sca))
						    )
						    (command ^ "_.line" w_zd_p w_locp "")
						    (command ^ "_.line" w_endp w_locp "")
						    (setq w_bg_str (Dl_TrimRight0 (rtos w_the_bg 2 nPrec)))
						    (setq w_txtp (midpt w_locp w_endp)
							  			w_txtp (polar w_txtp (* pi 0.5) (/ 0.5 wg_sca))
						    )
						    (command ^ "_.text" "j" "BC" w_txtp wg_txth 0 w_bg_str)
				    	)
				    )	    
				    
				    
				    
				  )
				)
      )
    )
  )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;功能：取交叉口数据
;;参数：xc_zhcode　桩号代号 nil 表示取主道路
;;返回值:((桩号1 (交叉道路方向列表)) (桩号2 (交叉道路方向列表)....)
;;注意：返回值排过序
(defun get_jck( xc_zhcode / ent stake w_main_stk w_glb
								w_ssdl w_lnkb lnk jck jck_list sub_jck 
								ent ang road_ang ang_list w_pde)
	(#ppas "Drawroad")
	(szload hy_ss_con "hy_dlzh")
 (if xc_zhcode
    (setq w_main_stk xc_zhcode)
    (setq w_main_stk (DL_GetMainStake))
  )
  (setq w_main_stk (DL_GetMainStake))
  (if w_main_stk
    (progn
      (setq w_zhappn (strcat "DLZH_" w_main_stk)
	    w_glb    (list (cons 8 "AXIS") (list -3 (list w_zhappn)));;;选择某桩号的中心线
      )      
      (setq w_ssdl (ssget "x" w_glb))
    )
  )
  (if w_ssdl
    (progn
			(setq w_lnkb (hy_ss_con w_ssdl 0.001 2));;;判断一个选择集是否连续如果连续返回一个顺序链表否则返回空	
		  (if w_lnkb
			  (setq w_lnkb (zh_lnkb_px w_lnkb 0.001));;;对链表排序使链表的点序与桩号顺序一致	
		  )
		  (foreach lnk w_lnkb
		  	(setq ent (cadr lnk))
		  	(if (and ent (= (type ent) 'ENAME))
		  		(progn
		  			(setq sub_jck (HY_GetCrossAxis ent))
				  	(setq sub_jck (merge_jck sub_jck))
				  	(foreach jck  sub_jck
				  		(setq jck (crectjck jck))
					  	(if jck
					  		(setq jck_list (cons jck jck_list))
					  	)
				  	)
		  		)
		  	)
		  	
		  )
		  (if jck_list
		  	(setq jck_list ($xsort_lst jck_list))
		  )
		)
	)
	jck_list
)

;;插入纵断表头
;;编写：lxf
(defun hyzdm_insert_zdbt ( xc_basp xc_xsc xc_yxc / w_file L_fildFlag ss ent ent1 ent2)
      (setq w_file        (strcat wg_user_path "\\hyszzdbt.dwg")
      	    L_fildFlag    nil
      )
      
      (if (findfile w_file)
        (setq L_fildFlag t)
        (progn
          (setq w_file (strcat wg_soft_path hyszdl_gv_sys_dir)
                w_file (strcat w_file "\\hyszzdbt.dwg")
          )
          (if (findfile w_file)
            (setq L_fildFlag t)
          )
        )
      )
      (if L_fildFlag
				(progn
					(setq ent1 (entlast))
					(setq w_file (strcat "*" w_file))
					(command "_.insert" w_file  xc_basp  xc_xsc   0 )
					(setq ent2  (entlast))
					(if ent1 
						(setq ent1 (entnext ent1)) 
						(setq ent1 ent2)
					)
					;;;;(setq ent1 (entnext ent1))
					(setq flag t)
					(while ent1
						(command "_.chprop" ent1 "" "layer" wg_btbc_layer "")
						(setq ent1 (entnext ent1))
					)
				)
				(DL_MsgOK "系统被破坏，纵断表头图块文件找不到!")
      )
)
;;;二、标尺绘制
;;;    1. 函数名
;;;       hyzdm_draw_rule
;;;    2. 参数
;;;       (1) xc_basp -- 标尺底部的右侧点
;;;    3. 直接引用的外部变量
;;;       (1)wg_rule_ah -- 标尺代表的总高程(米)
;;;          数据类型 -- 实数
;;;       (2)wg_yscale -- 竖向的放缩系数
;;;          数据类型 -- 实数
;;;       (3)wg_rule_bg0 -- 标尺基点代表的标高(米)
;;;          数据类型 -- 实数
;;;       (4)wg_txth -- 标注的文字高度
;;;          数据类型 -- 实数
;;;       (5)wg_sca -- 全图的比例系数
;;;          数据类型 -- 实数
;;;       (6)wg_btbl_layer -- 标尺所在的层
;;;    4.算法简述
;;;      参照附图,竖向高程必须乘以wg_yscale,以一米为间隔,在标尺左侧标注一个标高值,
;;;      与标尺的间距为(/ 0.5 wg_sca),对齐方式为"MR"
;;;      标尺总宽在函数开始处定义一个变量w_rult_wid = (/ 1.0 wg_sca)
(defun hyzdm_draw_rule (xc_basp	    /		w_base_wid  w_pi05
			w_lbasp	    w_basp	w_ltopp	    w_rtopp
			w_txtp	    w_step_bg	w_lstep_p   w_rstep_p
			w_old_plwid w_lup	w_rup	    w_txt_str
		       )
;;;w_base_wid -- 标尺的1/4宽度
	(setq nPrec (DL_GetDimPrec))
  (setq	w_base_wid (/ 0.25 wg_sca)
	w_pi05	   (* pi 0.5)
  )
;;;首先绘制标尺外框线
  (setq	w_lbasp	(polar xc_basp pi (* w_base_wid 4.0))
	w_ltopp	(polar w_lbasp w_pi05 (* wg_rule_ah wg_yscale))
	w_rtopp	(polar w_ltopp 0 (* w_base_wid 4.0))
  )
  (command ^ "_.line" xc_basp w_rtopp w_ltopp w_lbasp xc_basp "")
;;;标注基点标高
  (setq w_txtp (polar w_lbasp pi (/ 0.5 wg_sca)))
  (command ^ "_.text"
	   "j"
	   "MR"
	   w_txtp
	   wg_txth
	   0
	   (itoa wg_rule_bg0)
  )
;;;绘制每米的标识线并且标注标高
  (setq	w_step_bg 1
	w_lstep_p (polar w_lbasp 0 w_base_wid)
	w_rstep_p (polar xc_basp pi w_base_wid)
  )
  (setq w_old_plwid (getvar "plinewid"))
  (setvar "plinewid" (* w_base_wid 2.0))
  (while (< w_step_bg wg_rule_ah)
    (setq w_lup	    (polar w_lstep_p w_pi05 wg_yscale)
	  w_rup	    (polar w_rstep_p w_pi05 wg_yscale)
	  w_txtp    (polar w_txtp w_pi05 wg_yscale)
	  w_txt_str (itoa (+ wg_rule_bg0 w_step_bg))
    )
    (if	(= (rem w_step_bg 2) 0)
      (command ^ "_.pline" w_lstep_p w_lup "")
      (command ^ "_.pline" w_rstep_p w_rup "")
    )
    (command ^ "_.text" "j" "MR" w_txtp wg_txth 0 w_txt_str)
    (setq w_step_bg (1+ w_step_bg)
	  w_lstep_p w_lup
	  w_rstep_p w_rup
    )
  )
  (setq	w_lup	  (polar w_ltopp 0 w_base_wid)
	w_rup	  (polar w_rtopp pi w_base_wid)
	w_txtp	  (polar w_lbasp w_pi05 (* wg_rule_ah wg_yscale))
	w_txtp	  (polar w_txtp pi (/ 0.5 wg_sca))
	w_txt_str (Dl_TrimRight0 (rtos (+ wg_rule_bg0 wg_rule_ah) 2 nPrec))
  )
  (if (= (rem w_step_bg 2) 0)
    (command ^ "_.pline" w_lstep_p w_lup "")
    (command ^ "_.pline" w_rstep_p w_rup "")
  )
  (command ^ "_.text" "j" "MR" w_txtp wg_txth 0 w_txt_str)

  (setvar "plinewid" w_old_plwid)
)
;;;三、网格绘制
;;;    1. 函数名
;;;       hyzdm_draw_net
;;;    2. 参数
;;;       (1) xc_basp -- 网格左下角基点
;;;       (2) xc_len -- 网格长度
;;;    3. 直接引用的外部变量
;;;       (1)wg_rule_ah -- 标尺代表的总高程(米)
;;;          数据类型 -- 实数
;;;       (2)wg_yscale -- 竖向的放缩系数
;;;          数据类型 -- 实数
;;;       (3)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (4)wg_wg_layer -- 网格所在的层
;;;    4.算法简述
;;;      每一根横线代表一个整的标高值，按一米向上递增，竖线的间距与横线相同
(defun hyzdm_draw_net (xc_basp xc_len / w_step_bg w_lp w_rp w_pi05 w_step_x w_alen w_dp w_up w_ah)
  (setq	w_step_bg 0
	w_lp xc_basp
	w_pi05 (* pi 0.5)
        w_alen (* xc_len wg_xscale)
  )
  (while (<= w_step_bg wg_rule_ah)
    (setq w_rp (polar w_lp 0 w_alen))
    (command ^ "_.line" w_lp w_rp "")
    (setq w_lp (polar w_lp w_pi05 wg_yscale))
    (setq w_step_bg (1+ w_step_bg))
  )
  (setq w_dp xc_basp w_step_x 0 w_ah (* wg_rule_ah wg_yscale))
  (while (< w_step_x w_alen)
    (setq w_up (polar w_dp w_pi05 w_ah))
    (command ^ "_.line" w_dp w_up "")
    (setq w_dp (polar w_dp 0 wg_yscale))
    (setq w_step_x (+ w_step_x wg_yscale))
  )
  (setq w_dp (polar xc_basp 0 w_alen)
        w_up (polar w_dp w_pi05 w_ah)
  )
  (command ^ "_.line" w_dp w_up "")
)
;;;四、自然地面线绘制
;;;    1. 函数名
;;;       hyzdm_draw_zrx
;;;    2. 参数
;;;       (1) xc_basp -- 网格左下角基点
;;;       (2) xc_bash -- 网格左下角基点代表的高程
;;;       (3) xc_szh  -- 开始桩号
;;;       (4) xc_ezh  -- 结束桩号
;;;       (5) xc_zrbglist -- 本段自然标高表
;;;    3. 直接引用的外部变量
;;;       (1)wg_zrbg_list -- 读取自然标高数据
;;;       (2)wg_yscale -- 竖向的放缩系数
;;;          数据类型 -- 实数
;;;       (3)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (4)wg_zrx_layer -- 自然地面线所在的层
;;;    4.算法简述
;;;      对wg_zrbg_list做循环,
;;;        对于每一项,若桩号在起始桩号之间则根据桩号计算与基点的横向偏移距离
;;;        (wg_zrbg_list中的第一项即为基点的桩号),
;;;        根据标高计算与基点的竖向偏移距离,求出自然标高折点的点表,
;;;      根据点表绘制成多义线
(defun hyzdm_draw_zrx (xc_basp	 xc_bash   xc_szh    xc_ezh
		       xc_zrbglist	   /	     w_pi05
		       w_sbg	 w_gc	   w_offy    w_sp
		       w_ebg	 w_ep	   w_zrptb   w_zrbg
		       w_zh	 w_bg1	   w_bg2     w_offx
		       w_basp	 w_pt	   w_old_plwid
		       w_szrbg	 w_ezrbg    L_ptTmp ent
		      )
  (setq w_pi05 (* pi 0.5))
  (setq	w_szrbg	(car xc_zrbglist)
	w_ezrbg	(last xc_zrbglist)
  )
  (setq	w_sbg	(cadr w_szrbg)
	w_gc	(- w_sbg wg_rule_bg0)
	w_offy	(* w_gc wg_yscale)
	w_sp	(polar xc_basp w_pi05 w_offy)
	w_zrptb	(cons w_sp w_zrptb)
  )
  (setq w_sbg (caddr w_szrbg))
  (if w_sbg
    (setq w_gc	  (- w_sbg wg_rule_bg0)
	  w_offy  (* w_gc wg_yscale)
	  w_sp	  (polar xc_basp w_pi05 w_offy)
	  w_zrptb (cons w_sp w_zrptb)
    )
  )
  (foreach w_zrbg wg_zrbg_list
    (setq w_zh (car w_zrbg))
    (if	(and (> w_zh xc_szh) (< w_zh xc_ezh))
      (progn
	(setq
	  w_bg1	 (cadr w_zrbg)
	  w_bg2	 (caddr w_zrbg)
	  w_offx (* wg_xscale (- w_zh xc_szh))
	  w_basp (polar xc_basp 0 w_offx)
	)
	(if w_bg1
	  (progn
	    (setq w_gc	  (- w_bg1 xc_bash)
		  w_offy  (* w_gc wg_yscale)
		  w_pt	  (polar w_basp w_pi05 w_offy)
		  w_zrptb (cons w_pt w_zrptb)
	    )
	  )
	)
	(if w_bg2
	  (progn
	    (setq w_gc	  (- w_bg2 xc_bash)
		  w_offy  (* w_gc wg_yscale)
		  w_pt	  (polar w_basp w_pi05 w_offy)
		  w_zrptb (cons w_pt w_zrptb)
	    )
	  )
	)
      )
    )
  )
  (setq w_ebg (caddr w_ezrbg))
  (if w_ebg
    (setq w_gc	  (- w_ebg xc_bash)
	  w_offy  (* w_gc wg_yscale)
	  w_ep	  (polar xc_basp 0 (* wg_xscale (- xc_ezh xc_szh)))
	  w_ep	  (polar w_ep w_pi05 w_offy)
	  w_zrptb (cons w_ep w_zrptb)
    )
  )
  (setq	w_ebg	(cadr w_ezrbg)
	w_gc	(- w_ebg xc_bash)
	w_offy	(* w_gc wg_yscale)
	w_ep	(polar xc_basp 0 (* wg_xscale (- xc_ezh xc_szh)))
	w_ep	(polar w_ep w_pi05 w_offy)
	w_zrptb	(cons w_ep w_zrptb)
  )
  (setq w_old_plwid (getvar "plinewid"))
  (setvar "plinewid" (DL_GetLayerLineWidth wg_zrx_layer))
  (command ^ "_.pline")
  (foreach w_pt	w_zrptb
    (command w_pt)
  )
  (command "")
  (setvar "plinewid" w_old_plwid)
 (setq ent (entlast))
  (if (= L_IsDrawSx 1);;是否在转折点绘制计划竖线-wg_head_bp
    (progn
        (foreach w_pt	w_zrptb
	  	(setq  L_ptTmp (list (car w_pt) (cadr wg_head_bp) 0))
    		(command "line" L_ptTmp w_pt "")
  	)
    )
  )
  ent
)
;;;六、填写设计坡度与距离
;;;    1. 函数名
;;;       hyzdm_pdjl_row
;;;    2. 参数
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度 -- 实数
;;;       (3) xc_prec -- 标注位数 -- 整数
;;;       (4) xc_0bq  -- 小数位是否用0补齐 1 - 补齐 0 - 不补齐
;;;       (5) xc_szh  -- 该段起点桩号 -- 实数
;;;       (6) xc_ezh  -- 该段终点桩号 -- 实数
;;;       (7) xc_bglist -- 该段的设计标高数据(桩号 标高 矫正值),矫正值可能不存在
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;       (4)wg_sjbg_list -- 设计标高数据表
;;;       (5)wg_slp_mode -- 坡度模式
;;;       (6)wg_slp_sign -- 是否标注坡度符号
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      从 xc_bglist 终提取起点标高 w_sbg 和终点标高 w_ebg, 不考虑矫正值
;;;      初始化设计标高折点表 w_zhbg_list 为空
;;;      对 wg_sjbg_list 做循环,
;;;         对于每一项,提取其桩号w_zh,
;;;         如果(xc_szh < w_zh < xc_ezh)
;;;             提取折点标高 w_bg, (setq w_zhbg_list (cons (list w_zh w_bg) w_zhbg_list))
;;;      结束循环
;;;      初始化起点桩号 w_zh0 = xc_szh 起点标高 w_bg0 = w_sbg
;;;      对 4g_list 做循环
;;;         对于每一项, 计算坡度、坡长,
;;;         如果坡度大于零,向上划斜线,标注坡度坡长;
;;;         如果坡度小于零,向下划斜线,标注坡度坡长;
;;;         否则, 在中间划水平线,0度方向标注坡度坡长(上方坡度,下方坡长).
;;;         绘制垂直线,线左侧90度方向标注桩号
;;;         更新w_zh0 w_bg0的值为该项的值
;;;      结束循环
;;;      划左侧垂直短线和右侧垂直短线,划底部横线.
;;;      用w_zh0 w_bg0 和 xc_ezh w_ebg 做最后处理
;;;      注意坡长要乘以横向放缩系数 wg_xscale
(defun hyzdm_pdjl_row (xc_basp	 xc_wid	   xc_prec xc_0bq  xc_szh
		       xc_ezh	 xc_bglist /	     w_pi15
		       w_wid	 w_szh	   w_sbg     w_up0
		       w_dp0	 w_retp	   w_sjbg    w_zh
		       w_dist	 w_dist_txt	     w_up
		       w_dp	 w_bg	   w_gc	     w_pd
		       w_mp0	 w_mp	   w_dimp    w_dim_up
		       w_dim_dp	 w_pd_txt
		      )
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
;;;初始化起点标高
  (setq	w_szh  xc_szh
	w_sbg  (cadr (car xc_bglist))
	w_up0  xc_basp
	w_dp0  (polar w_up0 w_pi15 w_wid)
	w_retp w_dp0
  )

  (command ^ "_.line" w_up0 w_dp0 "")
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  (foreach w_sjbg wg_sjbg_list
;;;提取桩号计算距离并得到标注的距离文本
    (setq w_zh	     (nth 4 w_sjbg)
	  w_dist     (- w_zh w_szh)
	  w_dist_txt (rtos w_dist 2 xc_prec)
    )
    (setq w_zpc (hyzdm_zhgetpc w_zh))
    (if (equal w_dist w_zpc 0.0001)
        (princ)
        (setq w_dist_txt (strcat w_dist_txt " (" (rtos w_zpc 2 xc_prec) ")"))
     )
	  (if (/= xc_0bq 1)
 			(setq w_dist_txt (Dl_TrimRight0 w_dist_txt))
 		)
;;;如果找到标高折点在该桩号范围内
    (if	(and (> w_zh xc_szh) (< w_zh xc_ezh))
      (progn
;;;求垂直短线的两个端点
	(setq w_up (polar w_up0 0 (* wg_xscale w_dist))
	      w_dp (polar w_dp0 0 (* wg_xscale w_dist))
	)
	(command ^ "_.line" w_up w_dp "")
	(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
;;;计算高差坡度


;;;2002-4-23 任蔚青修改
	(setq w_bg (nth 5 w_sjbg)
	      w_gc (- w_bg w_sbg)
	    ;;;  w_pd (abs (/ w_gc w_dist))
	)

    (if (< (abs w_gc) 0.0001) (setq w_gc 0))
    (setq w_pd (abs (/ w_gc w_dist)))
;;;2002-4-23 任蔚青修改


;;;得到文本的基点w_dim_up和w_dim_dp
	(setq w_mp0    (midpt w_up0 w_dp0)
	      w_mp     (midpt w_up w_dp)
	      w_dimp   (midpt w_mp0 w_mp)
	      w_dim_up (polar w_dimp (* 0.5 pi) (* w_wid 0.25))
	      w_dim_dp (polar w_dimp w_pi15 (* w_wid 0.25))
	)
;;;根据设置得到要标注的坡度文本
	(cond
	  ((= wg_slp_mode 1)
;;;千分坡度
	   		(setq w_pd_txt (rtos (* w_pd 1000.0) 2 xc_prec))
	   		(if (/= xc_0bq 1)
	   			(setq w_pd_txt (Dl_TrimRight0 w_pd_txt))
	   		)
        (setq w_pd_txt (strcat w_pd_txt "‰"))
	  )
	  ((= wg_slp_mode 0)
;;;百分坡度
	   		(setq w_pd_txt (rtos (* w_pd 100.0) 2 xc_prec))
	   		(if (/= xc_0bq 1)
	   			(setq  w_pd_txt (Dl_TrimRight0 w_pd_txt))
	   		)
	      (setq w_pd_txt (strcat w_pd_txt "%"))
	  )
	  (t
;;;小数
	   		(setq w_pd_txt (rtos w_pd 2 xc_prec))
	   	  (if (/= xc_0bq 1)
	   			(setq w_pd_txt (Dl_TrimRight0 w_pd_txt))
	   		)
	  )
	)
;;;绘制标注--------------------------
	(cond
	  ((> w_gc 0)
;;;向上划斜线
	   (command ^ "_.line" w_dp0 w_up "")
	   (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
;;;得到坡度标注点和坡长标注点
	   (setq w_dim_up (polar w_dim_up pi (* w_dist wg_xscale 0.25))
		 w_dim_dp (polar w_dim_dp 0 (* w_dist wg_xscale 0.25))
	   )
	   (command ^ "_.text" "j" "MC" w_dim_up wg_txth 0 w_pd_txt)
	   (command ^ "_.text" "j" "MC" w_dim_dp wg_txth 0 w_dist_txt)
	  )
	  ((< w_gc 0)
;;;向下划斜线
	   (command ^ "_.line" w_up0 w_dp "")
	   (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
;;;得到坡度标注点和坡长标注点
	   (setq w_dim_up (polar w_dim_up 0 (* w_dist wg_xscale 0.25))
		 w_dim_dp (polar w_dim_dp pi (* w_dist wg_xscale 0.25))
	   )
	   (command ^ "_.text" "j" "MC" w_dim_up wg_txth 0 w_pd_txt)
	   (command ^ "_.text" "j" "MC" w_dim_dp wg_txth 0 w_dist_txt)
	  )
	  (t
;;;如果高差为零--中间绘制水平线
	   (command ^ "_.line" w_mp0 w_mp "")
	   (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
	   (command ^ "_.text" "j" "MC" w_dim_up wg_txth 0 w_pd_txt)
	   (command ^ "_.text" "j" "MC" w_dim_dp wg_txth 0 w_dist_txt)
	  )
	)

	(setq w_szh w_zh
	      w_sbg w_bg
	      w_up0 w_up
	      w_dp0 w_dp
	)
      )
    )
  )
;;;end (foreach w_sjbg wg_sjbg_list
;;;处理该段终点


;;;2002-4-23 任蔚青修改
  (setq	w_bg	   (cadr (last xc_bglist))
	w_zh	   xc_ezh
	w_dist	   (- w_zh w_szh)
	w_dist_txt (rtos w_dist 2 xc_prec)
	w_gc	   (- w_bg w_sbg)
	;;w_pd	   (abs (/ w_gc w_dist))
  )
  (setq w_zpc (hyzdm_zhgetpc w_zh))
	(if (equal w_dist w_zpc 0.0001)
	(princ)
	(setq w_dist_txt (strcat w_dist_txt " (" (rtos w_zpc 2 xc_prec) ")"))
	)
	(if (/= xc_0bq 1)
		(setq w_dist_txt (Dl_TrimRight0 w_dist_txt))
	)
  (if (< (abs w_gc) 0.0001) (setq w_gc 0))
  (setq w_pd (abs (/ w_gc w_dist)))
;;;2002-4-23 任蔚青修改



;;;求垂直短线的两个端点
  (setq	w_up (polar w_up0 0 (* wg_xscale w_dist))
	w_dp (polar w_dp0 0 (* wg_xscale w_dist))
  )
  (command "_.line" w_up w_dp "")
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
;;;得到文本的基点w_dim_up和w_dim_dp
  (setq	w_mp0	 (midpt w_up0 w_dp0)
	w_mp	 (midpt w_up w_dp)
	w_dimp	 (midpt w_mp0 w_mp)
	w_dim_up (polar w_dimp (* 0.5 pi) (* w_wid 0.25))
	w_dim_dp (polar w_dimp w_pi15 (* w_wid 0.25))
  )
;;;根据设置得到要标注的坡度文本
  (cond
    ((= wg_slp_mode 1)
;;;千分坡度
        (setq w_pd_txt (rtos (* w_pd 1000.0) 2 xc_prec))
     	  (if (/= xc_0bq 1)
	   			(setq w_pd_txt (Dl_TrimRight0 w_pd_txt))
	   		)
       (setq w_pd_txt (strcat w_pd_txt "‰"))
    )
    ((= wg_slp_mode 0)
;;;百分坡度
        (setq w_pd_txt (rtos (* w_pd 100.0) 2 xc_prec))
     	  (if (/= xc_0bq 1)
	   			(setq w_pd_txt (Dl_TrimRight0 w_pd_txt))
	   		)
       (setq w_pd_txt (strcat w_pd_txt "%"))
    )
    (t
;;;小数
     (setq w_pd_txt (rtos w_pd 2 xc_prec))
 	   	(if (/= xc_0bq 1)
 			(setq w_pd_txt (Dl_TrimRight0 w_pd_txt))
 		  )
    )
  )
;;;绘制标注
  (cond
    ((> w_gc 0)
;;;向上划斜线
     (command "_.line" w_dp0 w_up "")
     (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
;;;得到坡度标注点和坡长标注点
     (setq w_dim_up (polar w_dim_up pi (* w_dist wg_xscale 0.25))
	   w_dim_dp (polar w_dim_dp 0 (* w_dist wg_xscale 0.25))
     )
     (command "_.text" "j" "MC" w_dim_up wg_txth 0 w_pd_txt)
     (command "_.text" "j" "MC" w_dim_dp wg_txth 0 w_dist_txt)
    )
    ((< w_gc 0)
;;;向下划斜线
     (command "_.line" w_up0 w_dp "")
     (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
;;;得到坡度标注点和坡长标注点
     (setq w_dim_up (polar w_dim_up 0 (* w_dist wg_xscale 0.25))
	   w_dim_dp (polar w_dim_dp pi (* w_dist wg_xscale 0.25))
     )
     (command "_.text" "j" "MC" w_dim_up wg_txth 0 w_pd_txt)
     (command "_.text" "j" "MC" w_dim_dp wg_txth 0 w_dist_txt)
    )
    (t
;;;如果高差为零--中间绘制水平线
     (command "_.line" w_mp0 w_mp "")
     (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
     (command "_.text" "j" "MC" w_dim_up wg_txth 0 w_pd_txt)
     (command "_.text" "j" "MC" w_dim_dp wg_txth 0 w_dist_txt)
    )
  )
;;;绘制底部横线
  (command "_.line" w_retp w_dp "")
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)

;;;author wzy

(defun hyzdm_sqx_row ( xc_basp	  xc_wid     xc_prec xc_0bq	xc_szh
		       xc_ezh	  xc_bglist  /		w_pi15
		       w_wid	  w_sjbg     w_zh	w_bg
		       w_dbg	  w_bg_txt   w_dbg_txt	w_dist
		       w_offx	  w_dim_basp w_dimp	w_retp count flag sjbg
		      )
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
  (setq count 0)
  (setq w_sjbg (nth 0 xc_bglist))
  (setq w_dbg	(caddr w_sjbg))
;;  (if	(> (abs w_dbg) 0.0001)
;;  	(setq flag t);;;　T　当前为竖曲线
;;  	(setq flag nil)
;;  )
  (foreach w_sjbg xc_bglist
    (setq w_zh	(car w_sjbg)
	  w_bg	(cadr w_sjbg)
	  w_dbg	(caddr w_sjbg)
    )
   
    (setq w_dist     (- w_zh xc_szh)
	  w_offx     (* w_dist wg_xscale)
	  w_dim_basp (polar xc_basp 0 w_offx)
	  w_dimp     (polar w_dim_basp w_pi15 (* w_wid 0.5))
	  w_linebt   (polar w_dim_basp w_pi15 w_wid)
     )
     (if (= wg_biaotoushuxian 1)
     	 (setq w_dimp     (polar w_dimp pi wg_txtoffset))
    )
    (if	(> (abs w_dbg) 0.0001)
    	(progn
	        (setq w_bg_txt  (rtos (+ w_bg w_dbg) 2 xc_prec))
	   	(if (/= xc_0bq 1)
			(setq w_bg_txt (Dl_TrimRight0 w_bg_txt))
		)

	        (command "_.text" "j" "BC" w_dimp wg_txth 90 w_bg_txt)
	        (if (= wg_biaotoushuxian 1)
			(progn
				(command "_.line" w_dim_basp w_linebt "")
				(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
			)
	        )
		(setq flag t)
	)
      (progn
	(if flag 
		(progn
			(setq flag nil)
			(setq w_bg_txt (rtos w_bg  2 xc_prec))
			(if (/= xc_0bq 1)
 				(setq w_bg_txt (Dl_TrimRight0 w_bg_txt))
 		        )
			(command "_.text" "j" "BC" w_dimp wg_txth 90 w_bg_txt)
			(if (= wg_biaotoushuxian 1)
			    (progn
				(command "_.line" w_dim_basp w_linebt "")
				(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
			     )
			 )
		)
		(progn
			(setq sjbg (nth (1+ count) xc_bglist))
			(if (and sjbg (>= (abs (caddr sjbg)) 0.0001))
				(progn
					(setq flag t)
					(setq w_bg_txt (rtos w_bg  2 xc_prec))
					(if (/= xc_0bq 1)
			 				(setq w_bg_txt (Dl_TrimRight0 w_bg_txt))
			 		  )
					(command "_.text" "j" "BC" w_dimp wg_txth 90 w_bg_txt)
					(if (= wg_biaotoushuxian 1)
					    (progn
 						(command "_.line" w_dim_basp w_linebt "")
 						(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
 					     )
					)
				)
			)
		)
	)	
      )
    )
    (setq count (1+ count))
  );;;end of foreach
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)
;;;七、填写地面设计高程
;;;    1. 函数名
;;;       hyzdm_sjbg_row
;;;    2. 参数
;;;       ( ) wg_biaotoushuxian -- 是否绘制表头竖线
;;;       (0) w_index -- 用以区分设计标高的类别(设计标高A/设计标高B)
;;;           若w_index为1,表示为设计标高A,该栏的值为:加过竖曲线后的设计标高(未加竖曲线前的设计标高)
;;;           若w_index为14,表示为设计标高B,该栏的值为:未加竖曲线前的设计标高(加过竖曲线后的设计标高在"竖曲线"栏中填写)
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度
;;;       (3) xc_prec -- 该栏标注位数
;;;       (4) xc_0bq  -- 小数位是否用0补齐 1 - 补齐 0 - 不补齐
;;;       (5) xc_szh  -- 该段起点桩号 -- 实数
;;;       (6) xc_ezh  -- 该段终点桩号 -- 实数
;;;       (7) xc_bglist -- 该段的设计标高数据
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      对 xc_bglist 做循环,
;;;         对于每一项,提取其桩号 w_zh 标高 w_bg 和矫正值 w_dbg
;;;         根据 w_zh 和 xc_szh 计算横向偏移距离, 90 度方向标注矫正后的标高,
;;;         向右偏移半个字高加 1 毫米(考虑wg_sca)标注标高(加括号),
;;;         对齐点为中点,对齐方式 "MC"
;;;      结束循环
;;;      划底部横线.
(defun hyzdm_sjbg_row ( index xc_basp	  xc_wid     xc_prec xc_0bq	xc_szh
		       xc_ezh	  xc_bglist  /		w_pi15
		       w_wid	  w_sjbg     w_zh	w_bg
		       w_dbg	  w_bg_txt   w_dbg_txt	w_dist
		       w_offx	  w_dim_basp w_dimp	w_retp  w_linebp
		      )
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
  
  (setq xc_bglist (Zdm_DrawJCK 
					(list xc_bglist) 
					xc_basp 
					w_wid 
					wg_bldim_layer 
					wg_txth 
					wg_xscale)
					)
  
  (foreach w_sjbg xc_bglist
    (setq w_zh	(car w_sjbg)
	  w_bg	(cadr w_sjbg)
	  w_dbg	(caddr w_sjbg)
    )
    
    (if (and (= index 1) (> (abs w_dbg) 0.0001))
        (progn
		        (setq w_bg_txt  (rtos (+ w_bg w_dbg) 2 xc_prec)
		              w_dbg_txt (rtos w_bg 2 xc_prec)
		        )
						(if (/= xc_0bq 1)
							(setq w_dbg_txt (Dl_TrimRight0 w_dbg_txt))
					  )
		        (setq  w_dbg_txt (strcat "(" w_dbg_txt ")"))
      	)
      	(progn
				    (setq w_bg_txt  (rtos w_bg 2 xc_prec)
					   	 w_dbg_txt nil
				     )

				)
    )
	  (if (/= xc_0bq 1)
			(setq w_bg_txt (Dl_TrimRight0 w_bg_txt))
	  )
    (setq w_dist     (- w_zh xc_szh)
	  w_offx     (* w_dist wg_xscale)
	  w_dim_basp (polar xc_basp 0 w_offx)
	  w_dimp     (polar w_dim_basp w_pi15 (* w_wid 0.5))
	  w_linebp   (polar w_dim_basp w_pi15 w_wid)
    )
    (if (= wg_biaotoushuxian 1)
     	 (setq w_dimp     (polar w_dimp pi wg_txtoffset))
    )
    (command "_.text" "j" "BC" w_dimp wg_txth 90 w_bg_txt)
    (if	w_dbg_txt
      (progn
	(setq w_dimp (polar w_dimp 0 (* 2 wg_txtoffset)))
	(command "_.text" "j" "TC" w_dimp wg_txth 90 w_dbg_txt)
      )
    )
    (if (= wg_biaotoushuxian 1)
       (progn
    	(command "_.line" w_dim_basp w_linebp "")
    	(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
       )
    )
  )
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)
;;;八、填写原地面高程
;;;    1. 函数名
;;;       hyzdm_zrbg_row
;;;    2. 参数
;;;       (1) wg_biaotoushuju -- 是否绘制表头数据
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度
;;;       (3) xc_prec -- 该栏标注位数
;;;       (4) xc_0bq  -- 小数位是否用0补齐 1 - 补齐 0 - 不补齐
;;;       (5) xc_szh  -- 该段起点桩号 -- 实数
;;;       (6) xc_ezh  -- 该段终点桩号 -- 实数
;;;       (7) xc_zrbglist -- 该段的自然标高数据表
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      对 xc_zrbglist 做循环,
;;;         对于每一项,提取其桩号 w_zh 标高 w_bg1 和 w_bg2
;;;         根据 w_zh 和 xc_szh 计算横向偏移距离, 90 度方向标注 w_bg1,
;;;         如果 w_bg2 存在,向右偏移半个字高加 1 毫米(考虑wg_sca)标注 w_bg2(加括号),
;;;         对齐点为中点,对齐方式 "MC"
;;;      结束循环
;;;      划底部横线.
(defun hyzdm_zrbg_row ( xc_basp	  xc_wid     xc_prec	xc_0bq xc_szh
		       xc_ezh	  xc_zrbglist		/
		       w_pi15	  w_wid	     w_zrbg	w_zh
		       w_bg	  w_dbg	     w_bg_txt	w_dbg_txt
		       w_dist	  w_offx     w_dim_basp	w_dimp
		       w_retp     w_linebp
		      )
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
  (foreach w_zrbg xc_zrbglist
    (setq w_zh	   (car w_zrbg)
	  w_bg	   (cadr w_zrbg)
	  w_bg_txt (rtos w_bg 2 xc_prec)
	  w_dbg	   (caddr w_zrbg)
    )
   	(if (/= xc_0bq 1)
			(setq w_bg_txt (Dl_TrimRight0 w_bg_txt))
	  )
    (if	w_dbg
      (progn
	      (setq w_dbg_txt (rtos w_dbg 2 xc_prec))
			  (if (/= xc_0bq 1)
					(setq w_dbg_txt (Dl_TrimRight0 w_dbg_txt))
			  )
		    (setq w_dbg_txt (strcat "(" w_dbg_txt ")"))
    	)
      (setq w_dbg_txt nil)
    )
    
    (setq w_dist     (- w_zh xc_szh)
	  w_offx     (* w_dist wg_xscale)
	  w_dim_basp (polar xc_basp 0 w_offx)
	  w_dimp     (polar w_dim_basp w_pi15 (* w_wid 0.5))
	  w_linebp   (polar w_dim_basp w_pi15 w_wid)
    )
    (if (= wg_biaotoushuxian 1)
     	 (setq w_dimp     (polar w_dimp pi wg_txtoffset))
    )
    (command "_.text" "j" "BC" w_dimp wg_txth 90 w_bg_txt)
    (if	w_dbg_txt
      (progn
					(setq w_dimp (polar w_dimp 0 (* 2 wg_txtoffset)))
					(command "_.text" "j" "TC" w_dimp wg_txth 90 w_dbg_txt)
      )
    )
    (if (= wg_biaotoushuxian 1)
       (progn
     	(command "_.line" w_dim_basp w_linebp "")
     	(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
       )
    )
  )
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)
;;;九、填写路中填挖高
;;;    1. 函数名
;;;       hyzdm_twg_row
;;;    2. 参数
;;;       (0) wg_biaotoushuxian -- 是否绘制表头数据
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度
;;;       (3) xc_prec -- 该栏标注位数
;;;       (4) xc_0bq  -- 小数位是否用0补齐 1 - 补齐 0 - 不补齐	
;;;       (5) xc_szh  -- 该段起点桩号 -- 实数
;;;       (6) xc_ezh  -- 该段终点桩号 -- 实数
;;;       (7) xc_zrbglist -- 该段的自然标高数据表
;;;       (8) xc_bglist -- 该段的设计标高数据表
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      对 xc_zrbglist 和 xc_bglist 同步做循环,
;;;         对于 xc_zrbglist 的每一项,提取其桩号 w_zh 标高 w_bg1 和 w_bg2
;;;         对于 xc_bglist 的每一项,提取其桩号 w_zh 标高 w_bg 和矫正值 w_dbg
;;;         根据矫正后的设计标高计算填挖高,如果有两个自然高,计算两个,标注两个
;;;         根据 w_zh 和 xc_szh 计算横向偏移距离, 90 度方向标注填挖高,
;;;         如果存在第二个,向右偏移半个字高加 1 毫米(考虑wg_sca)标注(加括号),
;;;         对齐点为中点,对齐方式 "MC"
;;;      结束循环
;;;      划底部横线.
(defun hyzdm_twg_row ( xc_basp	 xc_wid	    xc_prec  xc_0bq  xc_szh
		      xc_ezh	 xc_zrbglist	       xc_bglist
		      /		 w_pi15	    w_wid      w_ii
		      w_alen	 w_zrbg	    w_sjbg     w_zh
		      w_zrg	 w_dzrg	    w_sjg      w_dsjg
		      w_twg	 w_twg_txt  w_dtwg_txt w_dist
		      w_offx	 w_dim_basp w_dimp     w_retp  w_linebp
		     )

  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
	w_ii   0
	w_alen (min (length xc_zrbglist) (length xc_bglist))
  )
  (while (< w_ii w_alen)
    (setq w_zrbg (nth w_ii xc_zrbglist)
	  w_sjbg (nth w_ii xc_bglist)
	  w_ii	 (1+ w_ii)
    )
    (setq w_zh	 (car w_zrbg)
	  w_zrg	 (cadr w_zrbg)
	  w_dzrg (caddr w_zrbg)
    )
    (setq w_sjg	 (cadr w_sjbg)
	  w_dsjg (caddr w_sjbg)
    )
    (if	w_dsjg
      (setq w_sjg (+ w_sjg w_dsjg))
    )
    (if (= L_twgIsHJgc 1);;填挖高是否含结构层
      (setq w_twg   (- w_sjg w_zrg wg_thickness))
      (setq w_twg   (- w_sjg w_zrg ))
    )
    (setq  w_twg_txt (rtos w_twg 2 xc_prec))
   	(if (/= xc_0bq 1)
				(setq w_twg_txt (Dl_TrimRight0 w_twg_txt))
	  )
    (if	w_dzrg
      (progn
		      (setq w_dtwg_txt (rtos (- w_sjg w_dzrg) 2 xc_prec))
		      (if (/= xc_0bq 1)
							(setq w_dtwg_txt (Dl_TrimRight0 w_dtwg_txt))
				  )
			    (setq w_dtwg_txt (strcat "(" w_dtwg_txt ")"))
    	)
      (setq w_dtwg_txt nil)
    )
    (setq w_dist     (- w_zh xc_szh)
	  w_offx     (* w_dist wg_xscale)
	  w_dim_basp (polar xc_basp 0 w_offx)
	  w_dimp     (polar w_dim_basp w_pi15 (* w_wid 0.5))
	  w_linebp   (polar w_dim_basp w_pi15 w_wid)
    )
    (if (= wg_biaotoushuxian 1)
     	 (setq w_dimp     (polar w_dimp pi wg_txtoffset))
    )    
    (command "_.text" "j" "BC" w_dimp wg_txth 90 w_twg_txt)
    (if	w_dtwg_txt
      (progn
	(setq w_dimp (polar w_dimp 0 (* 2 wg_txtoffset)))
	(command "_.text" "j" "TC" w_dimp wg_txth 90 w_dtwg_txt)
      )
    )
    (if (= wg_biaotoushuxian 1)
      (progn
    	(command "_.line" w_dim_basp w_linebp "")
    	(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
      )
    )
  )
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)
;;;十、填写填挖方
;;;    1. 函数名
;;;       hyzdm_twf_row
;;;    2. 参数
;;;       (0) wg_biaotoushuxian -- 是否绘制表头竖线
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度
;;;       (3) xc_prec -- 该栏标注位数
;;;       (4) xc_szh  -- 该段起点桩号 -- 实数
;;;       (5) xc_ezh  -- 该段终点桩号 -- 实数
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      暂时空着.
;;;      划底部横线.
(defun hyzdm_twf_row
       (xc_basp xc_wid xc_prec xc_szh xc_ezh / w_pi15 w_wid w_retp)
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)
;;;十一、填写间距
;;;    1. 函数名
;;;       hyzdm_jj_row
;;;    2. 参数
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度
;;;       (3) xc_prec -- 该栏标注位数
;;;       (4) xc_0bq  -- 小数位是否用0补齐 1 - 补齐 0 - 不补齐
;;;       (5) xc_zhlist -- 该段的桩号数据表
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      初始化-- w_zh0 = (car xc_zhlist)
;;;              xc_zhlist = (cdr xc_zhlist)
;;;              w_p00 (polar xc_basp (* 1.5 pi) (* (/ 该栏宽度 wg_sca) 0.5))
;;;      绘制开始的垂直线
;;;      对 xc_zhlist 做循环,
;;;         对于 xc_zhlist 的每一项,提取其桩号 w_zh,计算与 w_zh0 的桩号差 w_dzh
;;;         if(> w_dzh 10.0)
;;;           w_p11 = (polar w_p00 0 (w_dzh * wg_xscale))
;;;           w_p11 处绘制垂直线,在 w_p00 和 w_p11 的终点标注 w_dzh
;;;           文字方向 0 度,对齐方式 "MC"
;;;           w_p00 = w_p11 w_zh0 = w_zh
;;;        ;end if
;;;      结束循环
;;;      划底部横线.
;;;
(defun hyzdm_jj_row (xc_basp   xc_wid	 xc_prec xc_0bq  xc_zhlist /
		     w_pi15    w_wid	 w_retp	   w_fup     w_fdp
		     w_fzh     w_bzh	 w_dist	   w_dist_txt
		     w_offx    w_bup	 w_bdp	   w_dimp
		    )
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line" xc_basp w_retp "")
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  (setq	w_fup	  xc_basp
	w_fdp	  w_retp
	w_fzh	  (car xc_zhlist)
	xc_zhlist (cdr xc_zhlist)
  )
  (while (> (length xc_zhlist) 0)
    (setq w_bzh	     (car xc_zhlist)
	  xc_zhlist  (cdr xc_zhlist)
	  w_dist     (- w_bzh w_fzh)
	  w_dist_txt (rtos w_dist 2 xc_prec)
	  w_offx     (* wg_xscale w_dist)
	  w_bup	     (polar w_fup 0 w_offx)
	  w_bdp	     (polar w_fdp 0 w_offx)
	  w_dimp     (inters w_fup w_bdp w_fdp w_bup)
    )
    (if	(> w_dist 5.0)
      (progn
      	 	(if (/= xc_0bq 1)
		 				(setq w_dist_txt (Dl_TrimRight0 w_dist_txt))
		 		  )
					(command "_.text" "j" "MC" w_dimp wg_txth 0 w_dist_txt)
					(command "_.line" w_bup w_bdp "")
					(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
					(setq w_fup w_bup
					      w_fdp w_bdp
					      w_fzh w_bzh
					)
      )
    )
  )
  (command "_.line" w_retp w_bdp "")
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp

)
;;;十二、填写桩号
;;;    1. 函数名
;;;       hyzdm_zh_row
;;;    2. 参数
;;;       (0) wg_biaotoushuxian -- 是否绘制表头竖线
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度
;;;       (3) xc_prec -- 该栏标注位数
;;;       (4) xc_zhlist -- 该段的桩号数据表
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      初始化-- w_zh0 = (car xc_zhlist)
;;;              xc_zhlist = (cdr xc_zhlist)
;;;              w_p00 (polar xc_basp (* 1.5 pi) (* (/ 该栏宽度 wg_sca) 0.5))
;;;      在 w_p00 处标注 w_zh0,文字方向 90 度,对齐方式 "MC"
;;;      对 xc_zhlist 做循环,
;;;         对于 xc_zhlist 的每一项,提取其桩号 w_zh,计算与 w_zh0 的桩号差 w_dzh
;;;           w_p11 = (polar w_p00 0 (w_dzh * wg_xscale))
;;;           在 w_p11 处标注 w_zh,文字方向 90 度,对齐方式 "MC"
;;;           w_p00 = w_p11 w_zh0 = w_zh
;;;      结束循环
;;;      划底部横线.
(defun hyzdm_zh_row ( xc_basp   xc_wid	 xc_prec   xc_zhlist /
		     w_pi15    w_wid	 w_retp	   w_basp    w_zh0
		     w_zh      w_zh_txt	 w_offx	   w_dimp    w_linetp  w_linebp
		    )
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
  (setq	w_retp (polar xc_basp w_pi15 w_wid)
	w_basp (midpt xc_basp w_retp)
	w_zh0  (car xc_zhlist)
  )
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- (last xc_zhlist) w_zh0)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  (foreach w_zh xc_zhlist
    (setq w_zh_txt (Dl_StakeToDimStr w_zh w_zh))
    (setq w_offx (* wg_xscale (- w_zh w_zh0))
          w_dimp (polar w_basp 0 w_offx)
          w_linetp (polar xc_basp 0 w_offx)
          w_linebp (polar w_retp 0 w_offx)
    )
    (if (= wg_biaotoushuxian 1)
     	 (setq w_dimp     (polar w_dimp pi wg_txtoffset))
    )
    (command "_.text" "j" "BC" w_dimp wg_txth 90 w_zh_txt)
    (if (= wg_biaotoushuxian 1)
      (progn
    	(command "_.line" w_linetp w_linebp "")
    	(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
      )
    )
  )
  w_retp
)
;;;十三、填写交叉口(编号)
;;;    1. 函数名
;;;       hyzdm_jck_row
;;;    2. 参数
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度
;;;       (3) xc_prec -- 该栏标注位数
;;;       (4) xc_szh  -- 该段起点桩号 -- 实数
;;;       (5) xc_ezh  -- 该段终点桩号 -- 实数
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      暂时空着.
;;;      划底部横线.
(defun hyzdm_jck_row
       (xc_basp xc_wid xc_prec xc_szh xc_ezh / w_pi15 w_wid w_retp sub_jck_list jck mindpt)
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (setq mindpt (polar xc_basp w_pi15 (* 0.5 w_wid)))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  (foreach jck wg_jck_list
  	(if (or (and (>=(car jck) xc_szh) (<=(car jck) xc_ezh))
	         (equal (car jck) xc_szh 0.001) (equal (car jck) xc_ezh 0.001)
		)
  	    (progn 
  		(setq leng (length sub_jck_list))
  		(setq bFlag nil)
  		(setq i 0)
  		(while (and (< i leng) (= bFlag nil))
  		       (if (< (abs(- (car jck)  (car (nth i sub_jck_list)))) 0.001)
  		          (setq bFlag t)
  		       )
  		       (setq i (+ i 1))
  		)
  		(if (= bFlag nil)
  		    (setq sub_jck_list (cons jck sub_jck_list )) 
  	        )
  	    )
  	)
  );;

  (if sub_jck_list
  	(progn
  		;;(princ (list "\n sub_jck_list" sub_jck_list))
  		;;(getpoint "\n sdjfksdfskdjf")
  		(setq sub_jck_list (reverse sub_jck_list))
  		;;(princ "\n wg_xscale = ")(princ wg_xscale)(princ "\n\n")
  		;;(princ "\n wg_yscale = ")(princ wg_yscale)(princ "\n\n")
  		(setq jck_index (zdm_jck wg_xscale wg_yscale  mindpt wg_net_bp wg_bgs_file wg_rule_bg0 jck_index xc_szh xc_ezh (* 0.5 xc_wid) sub_jck_list))
  	)
  )
  w_retp
)
;;;十五、填写路面设计高比原地面高(填高)
(defun hyzdm_ubg_row ( xc_basp	 xc_wid	    xc_prec xc_0bq  xc_szh
		      xc_ezh	 xc_zrbglist	       xc_bglist
		      /		 w_pi15	    w_wid      w_ii
		      w_alen	 w_zrbg	    w_sjbg     w_zh
		      w_zrg	 w_dzrg	    w_sjg      w_dsjg
		      w_twg	 w_twg_txt  w_dtwg_txt w_dist
		      w_offx	 w_dim_basp w_dimp     w_retp  w_linebp
		     )

  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
	w_ii   0
	w_alen (min (length xc_zrbglist) (length xc_bglist))
  )
  (while (< w_ii w_alen)
    (setq w_zrbg (nth w_ii xc_zrbglist)
	  w_sjbg (nth w_ii xc_bglist)
	  w_ii	 (1+ w_ii)
    )
    (setq w_zh	 (car w_zrbg)
	  w_zrg	 (cadr w_zrbg)
	  w_dzrg (caddr w_zrbg)
    )
    (setq w_sjg	 (cadr w_sjbg)
	  w_dsjg (caddr w_sjbg)
    )
    (if	w_dsjg
      (setq w_sjg (+ w_sjg w_dsjg))
    )
    (if (= L_twgIsHJgc 1);;填挖高是否含结构层
       (setq w_twg	    (- w_sjg w_zrg wg_thickness))
       (setq w_twg	    (- w_sjg w_zrg))
    )
    
    (setq  w_twg_txt (rtos w_twg 2 xc_prec))
    (if	(> w_twg 0)
      (progn
 	(setq w_dist	 (- w_zh xc_szh)
	      w_offx	 (* w_dist wg_xscale)
	      w_dim_basp (polar xc_basp 0 w_offx)
	      w_dimp	 (polar w_dim_basp w_pi15 (* w_wid 0.5))
	      w_linebp   (polar w_dim_basp w_pi15 w_wid)
	)
	(if (/= xc_0bq 1)
			(setq w_twg_txt (Dl_TrimRight0 w_twg_txt))
        )
	     (if (= wg_biaotoushuxian 1)
	     	 (setq w_dimp     (polar w_dimp pi wg_txtoffset))
	    )       
	(command "_.text" "j" "BC" w_dimp wg_txth 90 w_twg_txt)
	(if (= wg_biaotoushuxian 1)
	    (progn
		(command "_.line" w_dim_basp w_linebp "")
		(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
	    )
	)
      )
    )
  )
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)
;;;十五、填写路面设计高比原地面低(挖深)
(defun hyzdm_dbg_row ( xc_basp	 xc_wid	    xc_prec xc_0bq   xc_szh 
		      xc_ezh	 xc_zrbglist	       xc_bglist
		      /		 w_pi15	    w_wid      w_ii
		      w_alen	 w_zrbg	    w_sjbg     w_zh
		      w_zrg	 w_dzrg	    w_sjg      w_dsjg
		      w_twg	 w_twg_txt  w_dtwg_txt w_dist
		      w_offx	 w_dim_basp w_dimp     w_retp   w_linebp
		     )

  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
	w_ii   0
	w_alen (min (length xc_zrbglist) (length xc_bglist))
  )
  (while (< w_ii w_alen)
    (setq w_zrbg (nth w_ii xc_zrbglist)
	  w_sjbg (nth w_ii xc_bglist)
	  w_ii	 (1+ w_ii)
    )
    (setq w_zh	 (car w_zrbg)
	  w_zrg	 (cadr w_zrbg)
	  w_dzrg (caddr w_zrbg)
    )
    (setq w_sjg	 (cadr w_sjbg)
	  w_dsjg (caddr w_sjbg)
    )
    (if	w_dsjg
      (setq w_sjg (+ w_sjg w_dsjg))
    )
    (if (= L_twgIsHJgc 1);;填挖高是否含结构层
         (setq w_twg	    (- w_sjg w_zrg wg_thickness))
         (setq w_twg	    (- w_sjg w_zrg))
     ;;  这里原来求错了，2004-3-12 16:58
     ;;  (setq w_twg (- w_zrg w_sjg wg_thickness))
     ;;  (setq w_twg (- w_zrg w_sjg))
    )
    
    ;;(print (list w_zh  "挖" w_twg w_zrg w_sjg))
    (if	(< w_twg 0)
      (progn
	        (setq w_twg (abs w_twg))
	        (setq w_twg_txt (rtos w_twg 2 xc_prec))
	   	(if (/= xc_0bq 1)
				(setq w_twg_txt (Dl_TrimRight0 w_twg_txt))
		  )		    
	 	(setq w_dist	 (- w_zh xc_szh)
		      w_offx	 (* w_dist wg_xscale)
		      w_dim_basp (polar xc_basp 0 w_offx)
		      w_dimp	 (polar w_dim_basp w_pi15 (* w_wid 0.5))
		      w_linebp   (polar w_dim_basp w_pi15 w_wid)
		)
		(if (= wg_biaotoushuxian 1)
	     	 (setq w_dimp     (polar w_dimp pi wg_txtoffset))
	        )
		(command "_.text" "j" "BC" w_dimp wg_txth 90 w_twg_txt)
		(if (= wg_biaotoushuxian 1)
		    (progn
			(command "_.line" w_dim_basp w_linebp "");;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
		    )
		)
      )
    )
  )
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)
;;;十七、填写空栏
;;;    1. 函数名
;;;       hyzdm_kl_row
;;;    2. 参数
;;;       (1) xc_basp -- 表栏左上角基点
;;;       (2) xc_wid  -- 该栏的宽度
;;;       (3) xc_prec -- 该栏标注位数
;;;       (4) xc_0bq  -- 小数位是否用0补齐 1 - 补齐 0 - 不补齐		
;;;       (5) xc_szh  -- 该段起点桩号 -- 实数
;;;       (6) xc_ezh  -- 该段终点桩号 -- 实数
;;;       (7) xc_dbg  -- 空栏与中桩的高差
;;;       (8) xc_bglist -- 设计标高数据表
;;;    3. 直接引用的外部变量
;;;       (1)wg_xscale -- 横向的放缩系数
;;;          数据类型 -- 实数
;;;       (2)wg_btbl_layer -- 表头表栏所在的层
;;;       (3)wg_txth -- 字高
;;;
;;;    4.返回值
;;;      下一栏的基点
;;;    5.算法简述
;;;      对 xc_bglist 做循环,
;;;         对于 xc_bglist 的每一项,提取其桩号 w_zh 标高 w_bg 和矫正值 w_dbg
;;;         w_dim_bg = w_bg + w_dbg + xc_dbg
;;;         如果根据 w_zh 和 xc_szh 计算横向偏移距离, 90 度方向标注挖高(绝对值),
;;;         对齐点为中点,对齐方式 "MC"
;;;      结束循环
;;;      划底部横线.
(defun hyzdm_kl_row ( xc_basp	xc_wid	   xc_prec xc_0bq   xc_szh
		     xc_ezh	xc_dbg	   xc_bglist  /
		     w_pi15	w_wid	   w_sjbg     w_zh
		     w_bg	w_dbg	   w_bg_txt   w_dbg_txt
		     w_dist	w_offx	   w_dim_basp w_dimp
		     w_retp
		    )
  (setq	w_pi15 (* pi 1.5)
	w_wid  (/ xc_wid wg_sca)
  )
  
  
  (foreach w_sjbg xc_bglist
    (setq w_zh	(car w_sjbg)
	  w_bg	(cadr w_sjbg)
	  w_dbg	(caddr w_sjbg)
    )
    (if	w_dbg
      (setq w_bg (+ w_bg w_dbg))
    )
    (setq w_bg (+ w_bg xc_dbg))
    (setq w_bg_txt (rtos w_bg 2 xc_prec))
    (setq w_dist     (- w_zh xc_szh)
	  w_offx     (* w_dist wg_xscale)
	  w_dim_basp (polar xc_basp 0 w_offx)
	  w_dimp     (polar w_dim_basp w_pi15 (* w_wid 0.5))
	  w_linebp   (polar w_dim_basp w_pi15 w_wid)
    )
   	(if (/= xc_0bq 1)
			(setq w_bg_txt (Dl_TrimRight0 w_bg_txt))
	  )
    (if (= wg_biaotoushuxian 1)
     	 (setq w_dimp     (polar w_dimp pi wg_txtoffset))
    )	  
    (command "_.text" "j" "BC" w_dimp wg_txth 90 w_bg_txt)
    (if (= wg_biaotoushuxian 1)
       (progn
    	(command "_.line" w_dim_basp w_linebp "")
    	(command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
       )
    )
  )
  
  
  
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  w_retp
)

;;;本函数由王志宇编写 2003-3-28 16:04
;;;用于绘制超高图
;;;(基点 栏宽 小数位数 小数位是否用0补齐 起始桩号 结束桩号)
(defun hyzdm_cgt_row (xc_basp  xc_wid	xc_prec	xc_0bq xc_szh	  xc_ezh
		      /	       w_pi15	w_pi05	 w_wid	  w_retp
		      w_mbasp  	  w_prec
		     )
  (setq	w_pi15 (* pi 1.5)
	w_pi05 (* 0.5 pi)
	w_wid  (/ xc_wid wg_sca)
  )
  
  (setq	w_retp	(polar xc_basp w_pi15 w_wid)
	w_mbasp	(midpt xc_basp w_retp)
  )

  (pub_save_var)
  ;;2003-4-15 16:39(princ (list "\nsss" w_mbasp xc_szh xc_ezh xc_wid wg_xscale))
  ;;;(draw_cgt w_mbasp xc_szh xc_ezh xc_wid wg_xscale)
  (#ppas "ZdmDsgn")
  (Zdm_cgt w_mbasp xc_szh xc_ezh xc_wid wg_xscale wg_yscale xc_0bq xc_prec)
  ;;;(#ppuas "ZdmDsgn")
  (pub_re_var)
 
  
  (setq w_retp (polar xc_basp w_pi15 w_wid))
  (command "_.line"
	   w_retp
	   (polar w_retp 0 (* wg_xscale (- xc_ezh xc_szh)))
	   ""
  )
  (command "_.chprop" (entlast) "" "layer" wg_bldim_layer "")
  
  w_retp
  )

;;;功能相邻的交叉口合并
(defun merge_jck ( jck_list / angs ang stake jck ret_list ii )
	(while jck_list 
		(setq jck (car jck_list ))
		(setq jck_list (cdr jck_list))
		(setq ii 0)
		(while (< ii (length jck_list)) 
			(setq jck_next (nth  ii jck_list))
			(if (equal (car jck) (car jck_next) 3.0)
				(progn
					(setq jck (list (car jck) (append (cadr jck) (cadr jck_next))))
					(setq jck_list (#lstdel jck_list jck_next))
				)
				(setq ii (1+ ii))
			)
			
		)
		(setq ret_list (cons jck ret_list))
	)
	(reverse ret_list)
)
;;;把角度校正在0 - 2*pi内
(defun crectAngle ( ang /)
	(if ang 
		(progn
			(while ( > ang ( + (* 2 pi) 0.0001) )
				(setq ang ( - ang (* 2 pi)))
			)
			(while ( < ang  0.0001)
				(setq ang ( + ang (* 2 pi)))
			)
		)
	)
	ang
)
;;;修正交叉口过滤　角度0 pi
(defun crectJck ( jck / stake ang angs retangs )
	(setq stake (car jck))
	(setq angs (cadr jck))
	(foreach ang angs
		(setq ang (crectAngle ang))
		(if(null (and (equal ang 0.0 0.001) (equal ang pi 0.001)))
			(setq retangs (cons ang retangs))
		)
	)
	(if retangs
		(progn
			(setq retangs (reverse retangs))
			(setq jck (list stake retangs))
		)
		nil
	)

)

;;根据设计高数据，得到给定桩号处所在坡的总坡长
(defun hyzdm_zhgetpc (w_zh / w_bglist dzhpre dzhsucc isfind dpc )
      (setq w_bglist nil)
      (setq w_bglist (append w_bglist wg_sjbg_list)) 
      (setq dzhpre (nth 4(car w_bglist)))
      (setq w_bglist (cdr w_bglist))
      (setq isfind 0)
      (while (and (= isfind 0) w_bglist)
             (progn
             	(setq dzhsucc (nth 4 (car w_bglist)))
             	(if (and (>= w_zh dzhpre)(<= w_zh dzhsucc))
             	     (setq isfind 1)
             	     (progn
             	     	(setq dzhpre dzhsucc)
             	     	(setq w_bglist (cdr w_bglist))
             	     )
            	)
             )
      )
      (setq dpc (- dzhsucc dzhpre))
)