;;;------------BEGIN------------公用函数------------BEGIN------------
;;;绘制箭头--尖端起点，方向，箭头长，箭头宽，比例系数
(defun hy_arrow	(xc_sp	   xc_ang    xc_alen   xc_awid	 xc_sc
		 /	   w_ep	     w_ep1     w_ep2	 
		 w_rete
		)
  (setq	w_ep  (polar xc_sp xc_ang (/ xc_alen xc_sc))
	w_ep1 (polar w_ep (+ xc_ang (* pi 0.5)) (/ xc_awid xc_sc 2.0))
	w_ep2 (polar w_ep (- xc_ang (* pi 0.5)) (/ xc_awid xc_sc 2.0))
  )
  (command "solid" xc_sp w_ep1 w_ep2 "" "")
  (setq w_rete (entlast))
  w_rete
)
;;;绘制半箭头--尖端起点，方向，半宽方向，箭头长，箭头宽，比例系数
(defun hy_semi_arrow (xc_sp	 xc_ang1    xc_ang2    xc_alen
		      xc_awid	 xc_sc	    /	       w_ep
		      w_ep1	 w_rete
		     )
  (setq	w_ep  (polar xc_sp xc_ang1 (/ xc_alen xc_sc))
	w_ep1 (polar w_ep xc_ang2 (/ xc_awid xc_sc))
  )
  (command "solid" xc_sp w_ep w_ep1 "" "")
  (setq w_rete (entlast))
  w_rete
)
;;;绘制小短线--短线中心点，方向，短线长，短线宽，比例系数
(defun hy_short_line (xc_cp	 xc_ang	    xc_len     xc_wid
		      xc_sc	 /	    w_sp       w_ep
		      w_old_lwid w_ep1
		      w_rete
		     )
  (setq	w_sp (polar xc_cp xc_ang (/ xc_len xc_sc 2.0))
	w_ep (polar xc_cp (+ xc_ang pi) (/ xc_len xc_sc 2.0))
  )
  (setq w_old_lwid (getvar "plinewid"))
  (setvar "plinewid" (/ xc_wid xc_sc))
  (command "_.pline" w_sp w_ep "")
  (setq w_rete (entlast))
  (setvar "plinewid" w_old_lwid)
  w_rete
)
;;;提取标注设置
;;;xc_dim_set -- 读取的字符串，可以为空
;;;xc_sel:
;;; 0 -- 箭头长								 1 -- 箭头宽
;;; 2 -- 半箭头长						   3 -- 半箭头宽
;;; 4 -- 短斜线长							 5 -- 短斜线宽
;;; 6 -- 前端空白 						 7 -- 后端空白
;;; 8 -- 底部空白							 9 -- 尺寸线延伸长
;;;10 -- 尺寸界线延伸长			  11 -- 小圆点直径
(defun hy_get_dimset (xc_sel xc_dim_set / w_set_list w_retv)
  (if (null xc_dim_set)
    (if	(null (setq xc_dim_set (DL_GetPrjVal "DIM_ALL_SET")))
      (setq xc_dim_set
	     "3.0 0.25 3.0 0.15 2.0 0.25 0.5 0.5 0.5 1.0 1.0"
      )
    )
  )
  (setq w_set_list (HY_SeparateString xc_dim_set))
  (setq w_retv (read (nth xc_sel w_set_list)))
)
;;;  ------------END------------公用函数------------END------------

;;;------------BEGIN------------标注路宽------------BEGIN------------
(defun dim_act_lkbz (xc_lkb	 xc_dim_ang  xc_sel_pt	 xc_arrowtype
		     /		 w_llkb
		     w_rlkb	 w_lang	     w_rang	 w_basp
		     w_ldim_ptb	 w_llk	     w_dim_pt	 w_rdim_ptb
		     w_rlk	 w_dim_ptb   w_ii	 w_awid
		     w_len	 w_ret_ss    w_lp	 w_rp
		     w_midp	 w_dist	     w_dim_str	 w_txtp
		     w_limit_pl	 w_limit_pr  w_limit_lp	 w_limit_rp
		     w_newe
		    )

;;;;;;;;;;
	(if (null wg_bottom_offdist)
		(progn
			(if (null (setq w_dim_set (DL_GetPrjVal "DIM_ALL_SET")))
				(setq w_dim_set
				       "3.0 0.25 3.0 0.15 2.0 0.25 0.5 0.5 0.5 1.0 1.0"
				)
      )
      (setq wg_arrow_len      (hy_get_dimset 0 w_dim_set)
	    wg_arrow_wid      (hy_get_dimset 1 w_dim_set)
	    wg_semi_arrow_len (hy_get_dimset 2 w_dim_set)
	    wg_semi_arrow_wid (hy_get_dimset 3 w_dim_set)
	    wg_short_line_len (hy_get_dimset 4 w_dim_set)
	    wg_short_line_wid (hy_get_dimset 5 w_dim_set)
	    wg_fspace_dist    (hy_get_dimset 6 w_dim_set)
	    wg_bspace_dist    (hy_get_dimset 7 w_dim_set)
	    wg_bottom_offdist (hy_get_dimset 8 w_dim_set)
	    wg_limit_extdist  (hy_get_dimset 9 w_dim_set)
	    wg_dot_diameter   (hy_get_dimset 10 w_dim_set)
      )
		)
	)
	(if (null wg_sca)
		(setq wg_sca	(DL_GetDrawingFactor))
	)
	(if (null wg_texh)
		(setq wg_texh (Dl_GetTextHeight)) 
	)
			
;;;;;;;;
  (setq	w_llkb (cadr xc_lkb)
				w_rlkb (caddr xc_lkb)
				w_lang (+ xc_dim_ang (* 0.5 pi))
				w_rang (- xc_dim_ang (* 0.5 pi))
  )
  (setq	w_basp	   xc_sel_pt
				w_ldim_ptb '()
  )
  (foreach w_llk w_llkb
    (setq w_dim_pt (polar w_basp w_lang w_llk))
    (setq w_ldim_ptb (cons w_dim_pt w_ldim_ptb))
    (setq w_basp w_dim_pt)
  )
  (setq	w_basp	   xc_sel_pt
	w_rdim_ptb '()
  )
  (foreach w_rlk w_rlkb
    (setq w_dim_pt (polar w_basp w_rang w_rlk))
    (setq w_rdim_ptb (cons w_dim_pt w_rdim_ptb))
    (setq w_basp w_dim_pt)
  )
  (setq w_dim_ptb (append w_ldim_ptb (reverse w_rdim_ptb)))
  (setq	w_ii	 1
	w_awid	 0.0
	w_len	 (length w_dim_ptb)
	w_ret_ss (ssadd)
  )
  (command "dimstyle" "R" "RoadWidthDim")
  (setq wg_txw  (DL_GetDimPrec))
  (while (< w_ii w_len)
    (setq w_lp	    (nth (- w_ii 1) w_dim_ptb)
				  w_rp	    (nth w_ii w_dim_ptb)
				  w_midp    (midpt w_lp w_rp)
				  w_dist    (pmdist w_lp w_rp)
				  w_awid    (+ w_awid w_dist)
				  w_dim_str (rtos w_dist 2 wg_txw)
				  w_dim_str (Dl_TrimRight0 w_dim_str)
    )
;;;    (setq
;;;      w_txtp (polar w_midp xc_dim_ang (/ wg_bottom_offdist wg_sca))
;;;    )
;;;    (command "_.text"
;;;	     "j"
;;;	     "BC"
;;;	     w_txtp
;;;	     (/ wg_texh wg_sca)
;;;	     (rtod w_rang)
;;;	     w_dim_str
;;;    )
    (command "dimaligned" w_lp w_rp "T" w_dim_str w_rp)
    (ssadd (entlast) w_ret_ss)
    (setq w_ii (1+ w_ii))
  )
  (setq	w_lp (car w_dim_ptb)
	w_rp (last w_dim_ptb)
  )
;;;  (command "_.line" w_lp w_rp "")  
;;;  (ssadd (entlast) w_ret_ss)
  (setq	w_limit_pl (polar w_lp xc_dim_ang wg_limit_extdist)
	w_limit_pr (polar w_rp xc_dim_ang wg_limit_extdist)
	w_limit_lp (polar w_lp
			  (+ xc_dim_ang pi)
			  (/ (+ (* wg_texh 1.5) wg_bottom_offdist) wg_sca)
		   )
	w_limit_rp (polar w_rp
			  (+ xc_dim_ang pi)
			  (/ (+ (* wg_texh 1.5) wg_bottom_offdist) wg_sca)
		   )
  )
;;;  (command "_.line" w_limit_pl w_limit_lp "")
;;;  (ssadd (entlast) w_ret_ss)
;;;  (command "_.line" w_limit_pr w_limit_rp "")
;;;  (ssadd (entlast) w_ret_ss)
;;;  (command "_.line" w_limit_lp w_limit_rp "")
;;;  (ssadd (entlast) w_ret_ss)
  (setq	w_midp	  (midpt w_limit_lp w_limit_rp)
;;;	w_txtp	  (polar w_midp xc_dim_ang (/ wg_bottom_offdist wg_sca))
	w_dim_str (rtos w_awid 2 wg_txw)
	w_dim_str (Dl_TrimRight0 w_dim_str)

  )
;;;  (command "_.text"
;;;	   "j"
;;;	   "BC"
;;;	   w_txtp
;;;	   (/ wg_texh wg_sca)
;;;	   (rtod w_rang)
;;;	   w_dim_str
;;;  )
  (command "dimaligned" w_limit_lp w_limit_rp "T" w_dim_str w_limit_rp)
  (ssadd (entlast) w_ret_ss)
  (command "group" "c" "*" "" w_ret_ss "")
;;	(getpoint "\n 444")  
;;;  (cond
;;;    ((= xc_arrowtype "JT")
;;;     (setq w_newe (hy_arrow w_limit_lp
;;;			    w_rang
;;;			    wg_arrow_len
;;;			    wg_arrow_wid
;;;			    wg_sca
;;;		  )
;;;     )
;;;     (ssadd w_newe w_ret_ss)
;;;     (setq w_newe (hy_arrow w_limit_rp
;;;			    w_lang
;;;			    wg_arrow_len
;;;			    wg_arrow_wid
;;;			    wg_sca
;;;		  )
;;;     )
;;;     (ssadd w_newe w_ret_ss)
;;;     (setq w_ii	 1
;;;	   w_len (length w_dim_ptb)
;;;     )
;;;     (while (< w_ii w_len)
;;;       (setq w_lp   (nth (- w_ii 1) w_dim_ptb)
;;;	     w_rp   (nth w_ii w_dim_ptb)
;;;	     w_dist (pmdist w_lp w_rp)
;;;       )
;;;       (if (> w_dist (+ wg_arrow_len wg_arrow_len 2.0))
;;;	 (progn
;;;	   (setq w_newe	(hy_arrow w_lp
;;;				  w_rang
;;;				  wg_arrow_len
;;;				  wg_arrow_wid
;;;				  wg_sca
;;;			)
;;;	   )
;;;	   (ssadd w_newe w_ret_ss)
;;;	   (setq w_newe	(hy_arrow w_rp
;;;				  w_lang
;;;				  wg_arrow_len
;;;				  wg_arrow_wid
;;;				  wg_sca
;;;			)
;;;	   )
;;;	   (ssadd w_newe w_ret_ss)
;;;	 )
;;;	 (progn
;;;	   (command "_.donut"
;;;		    0.0
;;;		    (/ wg_dot_diameter wg_sca 2.0)
;;;		    w_lp
;;;		    ""
;;;	   )
;;;	   (ssadd (entlast) w_ret_ss)
;;;	   (command "_.donut"
;;;		    0.0
;;;		    (/ wg_dot_diameter wg_sca 2.0)
;;;		    w_rp
;;;		    ""
;;;	   )
;;;	   (ssadd (entlast) w_ret_ss)
;;;	 )
;;;       )
;;;       (setq w_ii (1+ w_ii))
;;;     )
;;;    )
;;;    ((= xc_arrowtype "BJT")
;;;     (setq w_newe (hy_semi_arrow
;;;		    w_limit_lp
;;;		    w_rang
;;;		    xc_dim_ang
;;;		    wg_semi_arrow_len
;;;		    wg_semi_arrow_wid
;;;		    wg_sca
;;;		  )
;;;     )
;;;     (ssadd w_newe w_ret_ss)
;;;     (setq w_newe (hy_semi_arrow
;;;		    w_limit_rp
;;;		    w_lang
;;;		    (+ xc_dim_ang pi)
;;;		    wg_semi_arrow_len
;;;		    wg_semi_arrow_wid
;;;		    wg_sca
;;;		  )
;;;     )
;;;     (ssadd w_newe w_ret_ss)
;;;     (setq w_ii	 1
;;;	   w_len (length w_dim_ptb)
;;;     )
;;;     (while (< w_ii w_len)
;;;       (setq w_lp   (nth (- w_ii 1) w_dim_ptb)
;;;	     w_rp   (nth w_ii w_dim_ptb)
;;;	     w_dist (pmdist w_lp w_rp)
;;;       )
;;;       (if (> w_dist (+ wg_semi_arrow_len wg_semi_arrow_len 2.0))
;;;	 (progn
;;;	   (setq w_newe	(hy_semi_arrow
;;;			  w_lp
;;;			  w_rang
;;;			  xc_dim_ang
;;;			  wg_semi_arrow_len
;;;			  wg_semi_arrow_wid
;;;			  wg_sca
;;;			)
;;;	   )
;;;	   (ssadd w_newe w_ret_ss)
;;;	   (setq w_newe	(hy_semi_arrow
;;;			  w_rp
;;;			  w_lang
;;;			  (+ xc_dim_ang pi)
;;;			  wg_semi_arrow_len
;;;			  wg_semi_arrow_wid
;;;			  wg_sca
;;;			)
;;;	   )
;;;	   (ssadd w_newe w_ret_ss)
;;;	 )
;;;	 (progn
;;;	   (command "_.donut"
;;;		    0.0
;;;		    (/ wg_dot_diameter wg_sca 2.0)
;;;		    w_lp
;;;		    ""
;;;	   )
;;;	   (ssadd (entlast) w_ret_ss)
;;;	   (command "_.donut"
;;;		    0.0
;;;		    (/ wg_dot_diameter wg_sca 2.0)
;;;		    w_rp
;;;		    ""
;;;	   )
;;;	   (ssadd (entlast) w_ret_ss)
;;;	 )
;;;       )
;;;       (setq w_ii (1+ w_ii))
;;;     )
;;;    )
;;;    (t
;;;     (setq w_newe (hy_short_line
;;;		    w_limit_lp
;;;		    (+ w_rang (* 0.25 pi))
;;;		    wg_short_line_len
;;;		    wg_short_line_wid
;;;		    wg_sca
;;;		  )
;;;     )
;;;     (ssadd w_newe w_ret_ss)
;;;     (setq w_newe (hy_short_line
;;;		    w_limit_rp
;;;		    (+ w_lang (* 0.25 pi))
;;;		    wg_short_line_len
;;;		    wg_short_line_wid
;;;		    wg_sca
;;;		  )
;;;     )
;;;     (ssadd w_newe w_ret_ss)
;;;     (setq w_ii	 0
;;;	   w_len (length w_dim_ptb)
;;;     )
;;;     (while (< w_ii w_len)
;;;       (setq w_lp (nth w_ii w_dim_ptb))
;;;       (setq w_newe (hy_short_line
;;;		      w_lp
;;;		      (+ w_lang (* 0.25 pi))
;;;		      wg_short_line_len
;;;		      wg_short_line_wid
;;;		      wg_sca
;;;		    )
;;;       )
;;;       (ssadd w_newe w_ret_ss)
;;;       (setq w_ii (1+ w_ii))
;;;     )
;;;    )
;;;  )
  w_ret_ss
)
;;;全路宽标注主函数
(defun dim_lkbz	(/		 w_glb		 w_ss
		 w_dim_set	 w_uctr		 w_arrowtype
		 w_bzjd		 w_plwid	 w_loop
		 w_bzpos	 w_cc		 w_ent
		 w_key		 w_sel_pt	 w_lkb
		 w_llkb		 w_rlkb		 w_dim_ang
		 wg_arrow_len	 wg_arrow_wid	 wg_semi_arrow_len
		 wg_semi_arrow_wid		 wg_short_line_len
		 wg_short_line_wid		 wg_bottom_offdist
		 wg_dot_diameter wg_sca		 wg_texh
		 wg_txw		 wg_limit_extdist
		 w_ss_ret
		 L_pt1           L_pt2           L_ss
		 L_ssLen         L_Dist
		 L_Flag
		)
  (szload pub_save_var "wwpublic")
  (#ppas "drawroad")
  (szload $set_p_on_e "pppp")  
  (pub_save_var)
  (command "osnap" "non")
  (setq w_glb '((8 . "AXIS") (0 . "LINE,*POLYLINE,ARC")))
  (setq	w_ss (ssget "x" w_glb))
  (if w_ss
    (progn
      (if (null (setq w_dim_set (DL_GetPrjVal "DIM_ALL_SET")))
	(setq w_dim_set
	       "3.0 0.25 3.0 0.15 2.0 0.25 0.5 0.5 0.5 1.0 1.0"
	)
      )
      (setq wg_arrow_len      (hy_get_dimset 0 w_dim_set)
	    wg_arrow_wid      (hy_get_dimset 1 w_dim_set)
	    wg_semi_arrow_len (hy_get_dimset 2 w_dim_set)
	    wg_semi_arrow_wid (hy_get_dimset 3 w_dim_set)
	    wg_short_line_len (hy_get_dimset 4 w_dim_set)
	    wg_short_line_wid (hy_get_dimset 5 w_dim_set)
	    wg_bottom_offdist (hy_get_dimset 8 w_dim_set)
	    wg_limit_extdist  (hy_get_dimset 9 w_dim_set)
	    wg_dot_diameter   (hy_get_dimset 10 w_dim_set)
      )
      (setq w_uctr  (HY_ClearUNDO)
	    wg_sca  (DL_GetDrawingFactor)
	    wg_texh (Dl_GetTextHeight)
	    wg_txw  (DL_GetDimPrec)
      )
      (setq w_arrowtype (ppsgetcfg "lkbzarrow"))
      (if (or (null w_arrowtype) (= w_arrowtype ""))
	(setq w_arrowtype "BJT")
      )
      (setq w_bzjd (itoa wg_txw))
;;;			(setq w_plwid (/ (DL_GetLayerLineWidth "pp-dl-lkbz") wg_sca))
      (setq w_old_layer (getvar "clayer"))
      (DL_MakeLayer "pp-dl-lkbz")
      (styrem)
      (setq w_loop t)
      (while w_loop
;;;	(if (= w_bzpos "NEAR")
;;;	  (prompt "\n当前标注位置为选择点;")
;;;	  (prompt "\n当前标注位置为端点;")
;;;	)
;;;	(cond
;;;	  ((= w_arrowtype "JT")
;;;	   (prompt "当前箭头形式为箭头.")
;;;	  )
;;;	  ((= w_arrowtype "BJT")
;;;	   (prompt "当前箭头形式为半箭头.")
;;;	  )
;;;	  ((= w_arrowtype "DXX")
;;;	   (prompt "当前箭头形式为短斜线.")
;;;	  )
;;;	)
;;;	(prompt (strcat "当前小数点后保留位数是" w_bzjd "位"))
	(setq w_cc
	       "\n回车退出 / 回退 U / 栏选标注 F / 在道路中心线上点取标注点:"
	)

	(setq w_ent (HY_SelSingleEnt w_cc
			     "LINE,*POLYLINE,ARC"
			     "AXIS"
			     nil
			     "U S F"
		    )
	)

	(cond
	  ((null w_ent) (setq w_loop nil))
	  ((= w_ent "RETURN") (prompt "\n没选中指定实体!"))
	  ((= w_ent "U") ($undob w_uctr))
;;;	  ((= w_ent "S")
;;;	   (initget "A B")
;;;	   (setq w_key
;;;		  (getkword "\n确定箭头形式: 箭头 A / 半箭头 B / <短斜线>:"
;;;		  )
;;;	   )
;;;	   (cond
;;;	     ((= w_key "A") (setq w_arrowtype "JT"))
;;;	     ((= w_key "B") (setq w_arrowtype "BJT"))
;;;	     (T (setq w_arrowtype "DXX"))
;;;	   )
;;;	   (ppssetcfg "lkbzarrow" w_arrowtype)
;;;	  )
	  ((= w_ent "F")
	  	(setq L_Flag  t)
	  	;;;;;----11
	  	(while L_Flag
			(setq L_pt1 (getpoint "\n回车返回 / 点取篱笆线的起始点:"))
			(if L_pt1
				(progn
					(setq L_pt2 (getpoint L_pt1 "\n回车返回 / 点取篱笆线的结束点:"))
					(if(= L_pt2 nil)
						(setq L_Flag nil)
					)
				)
				(progn
					(setq L_Flag nil)
				)
			)
			;;+++++++
			(if L_Flag
				(progn
					(setq	L_ss (ssget "f"
					    (list L_pt1 L_pt2)
					    (list '(0 . "LINE,*POLYLINE,ARC")
						  (cons 8 "AXIS")
					    )
				   	  )
					)
					(if L_ss
						(setq L_ssLen (sslength L_ss))
						(setq L_ssLen 0)
					)

					(if (= L_ssLen 1)
						(progn
							(setq w_ent (ssname L_ss 0))
							(command "line" L_Pt1 L_pt2 "")
							(setq L_Dist (* 0.5 (distance L_Pt1 L_pt2)))
							;;(getpoint "\n4444")
							(setq  w_sel_pt (HY_intersectWith (entlast) w_ent 0))
							(entdel (entlast))
							;;(princ "\nw_sel_pt = ")(princ w_sel_pt)(getpoint "\n555")
							(if w_sel_pt
								(progn
									(setq w_sel_pt (car w_sel_pt))
								     	(setq w_lkb (arx_dllk w_ent w_sel_pt L_Dist L_Dist)
										 w_llkb	   (cadr w_lkb)
										 w_rlkb	   (caddr w_lkb)
										 w_dim_ang (DrawRoad_GetRoadAng w_ent w_sel_pt)
									)
									(HY_UndoM)
									(setq w_ss_ret (dim_act_lkbz
											    w_lkb
											    w_dim_ang
											    w_sel_pt
											    w_arrowtype
											  )
									 )
									 ;;(getpoint "\nee")
									 (initget "T")
									 (setq w_key (getkword "\n调整方向 T / <回车返回>:"))
									 (if w_key
									    (progn
									       ;;;(command "_.rotate" w_ss_ret "" w_sel_pt 180)
									       	(command "_.erase" w_ss_ret "")
										(setq w_lkb (Reverse_LKB__ w_lkb))
										;;(dim_act_lkbz w_lkb (+ w_dim_ang pi) w_sel_pt w_arrowtype)
									      	(setq w_ss_ret  (dim_act_lkbz w_lkb (+ w_dim_ang pi) w_sel_pt w_arrowtype))
										(setq index 0)
	       									(repeat (sslength w_ss_ret)
											(setq en (ssname w_ss_ret index))
											(setq en:data (entget en)
												val:51 (cdr (assoc 51 en:data))
												nval:51 (+ val:51 pi))
											(entmod (subst (cons 51 nval:51) (assoc 51 en:data) en:data))
											(setq index (+ index 1))
										)
									  )
									 )
								)
							)
						)
						(progn
							(princ "\n选择错误,请继续选择!!")
						)
					)
				)
			)
			;;;++++
		)
		;;;
	  )
	  (t
	   (setq w_sel_pt ($set_p_on_e w_ent)
		 w_ent	  (car w_ent)
	   )

     (setq w_lkb (arx_dllk w_ent w_sel_pt)
		 w_llkb	   (cadr w_lkb)
		 w_rlkb	   (caddr w_lkb)
		 w_dim_ang (DrawRoad_GetRoadAng w_ent w_sel_pt)
	   )

	   (HY_UndoM)
	   (setq w_ss_ret (dim_act_lkbz
			    w_lkb
			    w_dim_ang
			    w_sel_pt
			    w_arrowtype
			  )
	   )	   
	   (command "'zoom" "p")
	   (initget "T")
	   (setq w_key (getkword "\n调整方向 T / <回车返回>:"))
	   (if w_key
	     (progn
		(command "_.erase" w_ss_ret "")
		(setq w_lkb (Reverse_LKB__ w_lkb))
	       	(setq w_ss_ret  (dim_act_lkbz w_lkb (+ w_dim_ang pi) w_sel_pt w_arrowtype))
	       (setq index 0)
	       (repeat (sslength w_ss_ret)
		(setq en (ssname w_ss_ret index))
		(setq en:data (entget en)
			val:51 (cdr (assoc 51 en:data))
			nval:51 (+ val:51 pi))
		(entmod (subst (cons 51 nval:51) (assoc 51 en:data) en:data))
		(setq index (+ index 1))
		)
;;	       (command "_.rotate" w_ss_ret "" w_sel_pt 180)
;;;							 (command "_.mirror" w_ss_ret ""
;;;												(polar w_sel_pt (+ w_dim_ang (* 0.5 pi)) 100.0)
;;;												(polar w_sel_pt (- w_dim_ang (* 0.5 pi)) 100.0)
;;;												"Y"
;;;							 )
	     )
	   )
	  )
	)
      )
      (setvar "clayer" w_old_layer)
    )
    (prompt "\n 图中没有道路!")
  )
  (pub_re_var)
  (princ)
)
;;;功能 :路宽表左右互换
(defun Reverse_LKB__ ( xc_lkb / L_lkb L_11 )
	(setq L_11 (car xc_lkb)
	      L_11 (reverse L_11)
	      L_lkb (cdr xc_lkb)
	      L_lkb (reverse L_lkb)
	)
	(setq L_lkb (cons L_11 L_lkb))
	L_lkb
)
;;;------------END------------标注路宽------------END------------

;;;--------BEGIN-------------路宽交互标注---------BEGIN----------------
(defun dim_lkjhbz (/		   w_dim_set	   w_uctr
		   w_arrowtype	   w_bzjd	   w_old_layer
		   w_loop	   w_bzpos	   w_cc
		   w_ent	   w_key	   w_sel_pt
		   w_dim_ang	   w_ent2	   w_sel_pt2
		   w_temp_pt	   w_dim_pt2	   w_dim_dist
		   w_dim_txt	   w_txt_ang	   w_txt_pt
	           w_eb		   wg_arrow_len
		   wg_arrow_wid	   wg_semi_arrow_len
		   wg_semi_arrow_wid		   wg_short_line_len
		   wg_short_line_wid		   wg_bottom_offdist
		   wg_limit_extdist		   wg_dot_diameter
		   wg_sca	   wg_texh	   wg_txw
		  )
  (szload pub_save_var "wwpublic")
  (szload $set_p_on_e "pppp")
  (pub_save_var)
  (HY_Set0)
  (if (null (setq w_dim_set (DL_GetPrjVal "DIM_ALL_SET")))
    (setq w_dim_set
	   "3.0 0.25 3.0 0.15 2.0 0.25 0.5 0.5 0.5 1.0 1.0"
    )
  )
  (setq	wg_arrow_len	  (hy_get_dimset 0 w_dim_set)
	wg_arrow_wid	  (hy_get_dimset 1 w_dim_set)
	wg_semi_arrow_len (hy_get_dimset 2 w_dim_set)
	wg_semi_arrow_wid (hy_get_dimset 3 w_dim_set)
	wg_short_line_len (hy_get_dimset 4 w_dim_set)
	wg_short_line_wid (hy_get_dimset 5 w_dim_set)
	wg_bottom_offdist (hy_get_dimset 8 w_dim_set)
	wg_limit_extdist  (hy_get_dimset 9 w_dim_set)
	wg_dot_diameter	  (hy_get_dimset 10 w_dim_set)
  )
  (setq	w_uctr	(HY_ClearUNDO)
	wg_sca	(DL_GetDrawingFactor)
	wg_texh	(Dl_GetTextHeight)
	wg_txw	(DL_GetDimPrec)
  )
  (setq w_arrowtype (ppsgetcfg "lkbzarrow"))
  (if (or (null w_arrowtype) (= w_arrowtype ""))
    (setq w_arrowtype "BJT")
  )
  (setq w_bzjd (itoa wg_txw))
  (setq w_old_layer (getvar "clayer"))
  (DL_MakeLayer "pp-dl-lkbz")
  (styrem)
  (setq w_loop t)
  (while w_loop
;;;    (if	(= w_bzpos "NEAR")
;;;      (prompt "\n当前标注位置为选择点;")
;;;      (prompt "\n当前标注位置为端点;")
;;;    )
;;;    (cond
;;;      ((= w_arrowtype "JT")
;;;       (prompt "当前箭头形式为箭头.")
;;;      )
;;;      ((= w_arrowtype "BJT")
;;;       (prompt "当前箭头形式为半箭头.")
;;;      )
;;;      ((= w_arrowtype "DXX")
;;;       (prompt "当前箭头形式为短斜线.")
;;;      )
;;;    )
;;;    (prompt (strcat "当前小数点后保留位数是" w_bzjd "位"))
    (setq w_cc
	   "\n回车退出 / 回退 U / 点取第一条线:"
    )
    (setq w_ent	(HY_SelSingleEnt w_cc
			 "LINE"
			 nil
			 nil
			 "U S"
		)
    )
    (cond
      ((null w_ent) (setq w_loop nil))
      ((= w_ent "RETURN") (prompt "\n请选择直线段!"))
      ((= w_ent "U") ($undob w_uctr))
;;;      ((= w_ent "S")
;;;       (initget "A B")
;;;       (setq w_key
;;;	      (getkword	"\n确定箭头形式: 箭头 A / 半箭头 B / <短斜线>:"
;;;	      )
;;;       )
;;;       (cond
;;;	 ((= w_key "A") (setq w_arrowtype "JT"))
;;;	 ((= w_key "B") (setq w_arrowtype "BJT"))
;;;	 (T (setq w_arrowtype "DXX"))
;;;       )
;;;       (ppssetcfg "lkbzarrow" w_arrowtype)
;;;      )
      (t
       (setq w_sel_pt  ($set_p_on_e w_ent)
	     w_ent     (car w_ent)
	     w_eb      (entget w_ent)
	     w_dim_ang (angle (cdr (assoc 10 w_eb)) (cdr (assoc 11 w_eb)))
       )
       (setq w_ent2 ($p_to_e "\n回车退出 / 点取第二条线:"
			     "\n请选择直线段!"
			     '((0 . "LINE"))
			     512
		    )
       )
       (if w_ent2
	 (progn
	   (setq w_sel_pt2  ($set_p_on_e w_ent2)
		 w_temp_pt  (polar w_sel_pt (+ w_dim_ang (* 0.5 pi)) 100.0)
		 w_dim_pt2  ($qtyd1 w_sel_pt2 w_sel_pt w_temp_pt)
		 w_dim_dist (pmdist w_sel_pt w_dim_pt2)
		 w_dim_txt  (rtos w_dim_dist 2 wg_txw)
		 w_dim_txt  (Dl_TrimRight0 w_dim_txt)
		 w_txt_ang  (angle w_sel_pt w_dim_pt2)
		 w_txt_pt   (midpt w_sel_pt w_dim_pt2)
		 w_txt_pt   (polar w_txt_pt
				   (+ w_txt_ang (* 0.5 pi))
				   (/ wg_bottom_offdist wg_sca)
			    )
	   )
	   (HY_UndoM)
;;;	   (command "_.line" w_sel_pt w_dim_pt2 "")
;;;	   (command "_.text"
;;;		    "j"
;;;		    "BC"
;;;		    w_txt_pt
;;;		    (/ wg_texh wg_sca)
;;;		    (rtod w_txt_ang)
;;;		    w_dim_txt
;;;	   )
	   (command "dimaligned" w_sel_pt w_dim_pt2 "T" w_dim_txt w_dim_pt2)

;;;	   (cond
;;;	     ((= w_arrowtype "JT")
;;;	      (if (> w_dim_dist (+ wg_arrow_len wg_arrow_len 2.0))
;;;		(progn
;;;		  (hy_arrow w_sel_pt
;;;			    w_txt_ang
;;;			    wg_arrow_len
;;;			    wg_arrow_wid
;;;			    wg_sca
;;;		  )
;;;		  (hy_arrow w_dim_pt2
;;;			    (+ w_txt_ang pi)
;;;			    wg_arrow_len
;;;			    wg_arrow_wid
;;;			    wg_sca
;;;		  )
;;;		)
;;;		(progn
;;;		  (command "_.donut"
;;;			   0.0
;;;			   (/ wg_dot_diameter wg_sca 2.0)
;;;			   w_sel_pt
;;;			   ""
;;;		  )
;;;		  (command "_.donut"
;;;			   0.0
;;;			   (/ wg_dot_diameter wg_sca 2.0)
;;;			   w_dim_pt2
;;;			   ""
;;;		  )
;;;		)
;;;	      )
;;;	     )
;;;	     ((= w_arrowtype "BJT")
;;;	      (if
;;;		(> w_dim_dist
;;;		   (+ wg_semi_arrow_len wg_semi_arrow_len 2.0)
;;;		)
;;;		 (progn
;;;		   (hy_semi_arrow
;;;		     w_sel_pt
;;;		     w_txt_ang
;;;		     (+ w_txt_ang (* 0.5 pi))
;;;		     wg_semi_arrow_len
;;;		     wg_semi_arrow_wid
;;;		     wg_sca
;;;		   )
;;;		   (hy_semi_arrow
;;;		     w_dim_pt2
;;;		     (+ w_txt_ang pi)
;;;		     (- w_txt_ang (* 0.5 pi))
;;;		     wg_semi_arrow_len
;;;		     wg_semi_arrow_wid
;;;		     wg_sca
;;;		   )
;;;		 )
;;;		 (progn
;;;		   (command "_.donut"
;;;			    0.0
;;;			    (/ wg_dot_diameter wg_sca 2.0)
;;;			    w_sel_pt
;;;			    ""
;;;		   )
;;;		   (command "_.donut"
;;;			    0.0
;;;			    (/ wg_dot_diameter wg_sca 2.0)
;;;			    w_dim_pt2
;;;			    ""
;;;		   )
;;;		 )
;;;	      )
;;;	     )
;;;	     (t
;;;	      (hy_short_line
;;;		w_sel_pt
;;;		(+ w_txt_ang (* 0.25 pi))
;;;		wg_short_line_len
;;;		wg_short_line_wid
;;;		wg_sca
;;;	      )
;;;	      (hy_short_line
;;;		w_dim_pt2
;;;		(+ w_txt_ang (* 0.25 pi))
;;;		wg_short_line_len
;;;		wg_short_line_wid
;;;		wg_sca
;;;	      )
;;;	     )
;;;	   )
	 )
	 (setq w_loop nil)
       )
      )
    )
  )
  (setvar "clayer" w_old_layer)
  (pub_re_var)
  (princ)
)
;;;--------END-------------路宽交互标注---------END----------------

;;; --------BEGIN-----------标注车道-----------BEGIN--------------
(defun dim_cdbz	(/		w_glb	       w_ss
		 w_dim_set	w_uctr	       w_old_layer
		 w_loop		w_cc	       w_ent
		 w_sel_pt	w_cdlx	       w_lkb
		 w_llkb		w_rlkb	       w_awid
		 w_dim_ang	w_dirp	       w_dir_ang
		 w_temp_pt	w_endp	       w_iptb
		 w_distb	w_pt	       w_dist
		 w_add		wg_arrow_len   wg_arrow_wid
		 wg_semi_arrow_len	       wg_semi_arrow_wid
		 wg_short_line_len	       wg_short_line_wid
		 wg_fspace_dist	wg_bspace_dist wg_bottom_offdist
		 wg_limit_extdist	       wg_dot_diameter
		 wg_sca		wg_texh	       wg_txw
		 L_bFlag
		 L_pt1           L_pt2           L_ss
		 L_ssLen         L_Dist        L_strFlag
		 L_isF_to_P ;;t表示是从F方式切换到P方式
		)
  (szload pub_save_var "wwpublic")
  (#ppas "drawroad")
  (szload $set_p_on_e "pppp")
  (pub_save_var)
  (HY_Set0)
  (setq w_glb '((8 . "AXIS") (0 . "LINE,*POLYLINE,ARC")))
  (setq w_ss (ssget "x" w_glb))
  (if w_ss
    (progn
      (if (null (setq w_dim_set (DL_GetPrjVal "DIM_ALL_SET")))
	(setq w_dim_set
	       "3.0 0.25 3.0 0.15 2.0 0.25 0.5 0.5 0.5 1.0 1.0"
	)
      )
      (setq wg_arrow_len      (hy_get_dimset 0 w_dim_set)
	    wg_arrow_wid      (hy_get_dimset 1 w_dim_set)
	    wg_semi_arrow_len (hy_get_dimset 2 w_dim_set)
	    wg_semi_arrow_wid (hy_get_dimset 3 w_dim_set)
	    wg_short_line_len (hy_get_dimset 4 w_dim_set)
	    wg_short_line_wid (hy_get_dimset 5 w_dim_set)
	    wg_fspace_dist    (hy_get_dimset 6 w_dim_set)
	    wg_bspace_dist    (hy_get_dimset 7 w_dim_set)
	    wg_bottom_offdist (hy_get_dimset 8 w_dim_set)
	    wg_limit_extdist  (hy_get_dimset 9 w_dim_set)
	    wg_dot_diameter   (hy_get_dimset 10 w_dim_set)
      )
      (setq w_uctr  (HY_ClearUNDO)
	    wg_sca  (DL_GetDrawingFactor)
	    wg_texh (Dl_GetTextHeight)
	    wg_txw  (DL_GetDimPrec)
      )
      (styrem)
      (setq w_old_layer (getvar "clayer"))
      (DL_MakeLayer "pp-dl-bz")
      (setq w_loop t)
      (setq L_strFlag "P")
      (while w_loop
      	(setq L_isF_to_P nil)
	(if (= L_strFlag "P")
		(progn
			(setq w_cc "\n回车退出 / 回退 U / 栏选标注 F / 选择道路中心线引出标注点:")
	(setq w_ent
			       (HY_SelSingleEnt w_cc "LINE,*POLYLINE,ARC" "AXIS" nil "U F")
			)
		)
		(progn
			(setq w_ent "F")
		)
	)

	(setq L_bFlag nil)
	(cond
	  ((null w_ent) (setq w_loop nil))
	  ((= w_ent "RETURN") (prompt "\n没选中指定实体!"))
	  ((= w_ent "U") ($undob w_uctr))
	  ((= w_ent "F")
	  	;;;
	  	(setq L_strFlag "F")
		(setq L_pt1 (getpoint "\n回车返回 / 点取篱笆线的起始点:"))
		(if L_pt1
			(progn
				(setq L_pt2 (getpoint L_pt1 "\n回车返回 / 点取篱笆线的结束点:"))
				(if(= L_pt2 nil)
					(progn
						(setq L_strFlag "P")
						(setq L_isF_to_P t)
					)
				)
			)
			(progn
				(setq L_strFlag "P")
				(setq L_isF_to_P t)
			)
		)
		(if (= L_strFlag "F")
			(progn
				(setq	L_ss (ssget "f"
				    (list L_pt1 L_pt2)
				    (list '(0 . "LINE,*POLYLINE,ARC")
					  (cons 8 "AXIS")
				    )
			   	  )
		 		)
		 		(if L_ss
		 			(setq L_ssLen (sslength L_ss))
		 			(setq L_ssLen 0)
		 		)
		 		(if (= L_ssLen 1)
					(progn
						(setq w_ent (ssname L_ss 0))
						(command "line" L_Pt1 L_pt2 "")
						(setq L_Dist (* 0.5 (distance L_Pt1 L_pt2)))
						;;(getpoint "\n4444")
						(setq  w_sel_pt (HY_intersectWith (entlast) w_ent 0))
						(entdel (entlast))
						;;(princ "\nw_sel_pt = ")(princ w_sel_pt)(getpoint "\n555")
						(if w_sel_pt
							(progn
								(setq w_sel_pt (car w_sel_pt))
							     	;;;
						     		(HY_UndoM)
							      ;;;提取路宽，方向
							     (setq 	w_lkb (arx_dllk w_ent w_sel_pt L_Dist L_Dist)
									 w_llkb	   (cadr w_lkb)
									 w_rlkb	   (caddr w_lkb)
								  	 w_cdlx    (car w_lkb)
									 w_awid	   (+ (apply '+ w_llkb) (apply '+ w_rlkb))
									 w_dim_ang (DrawRoad_GetRoadAng w_ent w_sel_pt)
							     )
							     (setq L_bFlag t)
							     	;;;
							)
						)
					)
					(progn
						(princ "\n选择错误,请继续选择!!")
					)
				)
			)
		)
	  	;;;
	  )
	  (t
	   (HY_UndoM)
		;;修正选择点
	   (setq w_sel_pt ($set_p_on_e w_ent)
		 w_ent	  (car w_ent)
	;;	 w_cdlx	  (HY_QQ10xx w_ent "PP-AXIS" 1070)
	   )

;;;提取路宽，方向
     (setq w_lkb (arx_dllk w_ent w_sel_pt)
		 w_llkb	   (cadr w_lkb)
		 w_rlkb	   (caddr w_lkb)
	   w_cdlx    (car w_lkb)
		 w_awid	   (+ (apply '+ w_llkb) (apply '+ w_rlkb))
		 ;;w_dim_ang (#getepdir w_ent w_sel_pt) 
		 w_dim_ang (DrawRoad_GetRoadAng w_ent w_sel_pt)
	   )
	     (setq L_bFlag t)
	  )
	)
	;;(princ "\n w_lkb = ")(princ w_lkb)
	;;;;;;;;;;;;;;;lxf--start
	(if (and L_bFlag (= L_isF_to_P nil))
		(progn
;;;得到标注方向
	   (setq w_dirp (getpoint w_sel_pt "\n点示标注位置:"))
	   (if (null w_dirp)
	     (setq w_dir_ang (+ w_dim_ang (* 0.5 pi)))
	     (progn
	     	;;(princ "\n ---- ")
	     	(setq w_temp_pt (polar w_sel_pt (+ w_dim_ang (* 0.5 pi)) 100.0)
		  		 w_dirp    ($qtyd1 w_dirp w_sel_pt w_temp_pt)
		   		w_dir_ang (angle w_sel_pt w_dirp)
	    	)
	     )
	   )
   ;;;;add rwq 2002-10-21 8:57
		(if (or (< (abs (rem (- w_dir_ang (+ (* pi 0.5) w_dim_ang)) (* pi 2.0))) (* pi 0.5))
		        (> (abs (rem (- w_dir_ang (+ (* pi 0.5) w_dim_ang)) (* pi 2.0))) (* pi 1.5))
		    )
        (setq w_cdlx (nth 0 w_cdlx));;;左侧
        (setq w_cdlx (nth 1 w_cdlx));;;右侧
    )
    ;;(princ "\n w_cdlx = ")(princ w_cdlx)
    ;;;;add rwq 2002-10-21 8:57		

	   (setq w_endp (polar w_sel_pt w_dir_ang w_awid))
	   (zm2pt w_sel_pt w_endp)
	   (setq w_glb '((0 . "LINE,*POLYLINE,ARC") (8 . "ROAD,ROAD-1,XROAD")))
	   (setq w_ss (ssget "f" (list w_sel_pt w_endp) w_glb))	 	    
	   (if w_ss
	     (progn
	       (setq w_iptb (ipt_ess (list w_sel_pt w_endp) w_ss))
	       (setq w_iptb (mapcar 'car w_iptb))
	       (setq w_distb '())
	       (foreach	w_pt w_iptb
		 (setq w_dist  (pmdist w_sel_pt w_pt)
		       w_add   (list (car w_pt) (cadr w_pt) w_dist)
		       w_distb (cons w_add w_distb)
		 )		 
	       )

	       (if (>= (length w_distb) (length w_cdlx))
		 (progn
		   (setq w_distb (HY_PtbZSort w_distb))
		   (dim_act_cdbz
		     w_distb
		     w_dir_ang
		     w_cdlx
		     w_dirp
		     w_sel_pt
		   )
		 )
		 (prompt "\n请在包含全部车道的路段选择标注点!")
	       )
	     )
	   )


	  )
	)
      )
      (setvar "clayer" w_old_layer)
    )
    (prompt "\n 图中没有道路!")
  )
  (pub_re_var)
  (princ)
)
(defun dim_act_cdbz (xc_iptb	xc_ang	   xc_cdlx    xc_dirp
		     xc_sel_pt	/	   w_cd_list  w_line_len
		     w_off_dist	w_offd	   w_dim_pt   w_blen
		     w_ii	w_fpt	   w_bpt      w_mpt
		     w_end_pt	w_txt_pt  cd    i  len
		    )
  (setq i 0
        len   (length xc_cdlx)
        w_cd_list nil
  )

  (while (< i len)
         (setq cd  (nth i xc_cdlx))
         (cond ((= cd "K")
                (if (= len 1)
                    (setq w_cd_list (cons "车行道" w_cd_list))
                    (setq w_cd_list (cons "机动车道" w_cd_list ))
                )
               )
               ((= cd "L")
                (if (= i 0)
                    (setq w_cd_list (cons  "中央分隔带" w_cd_list))
　　　　　　　　　　(if (= i (1- len ))
　　　　　　　　　　     (setq w_cd_list (cons "绿化带" w_cd_list))
                         (setq w_cd_list (cons "分隔带" w_cd_list))
                    )
　　　　　　　　)
　　　　　　　 )
               ((= cd "M") (setq w_cd_list (cons "非机动车道" w_cd_list)))
               ((= cd "R") (setq w_cd_list (cons "人行道" w_cd_list)))
               (t nil)
        )
       (setq i (1+ i))
   )
  (setq w_cd_list (reverse w_cd_list))
  (setq	w_line_len ($txt_l "中央分隔带" (/ wg_texh wg_sca))
	w_line_len (+ w_line_len
		      (/ wg_fspace_dist wg_sca)
		      (/ wg_bspace_dist wg_sca)
		   )
	w_off_dist (/ (+ (* wg_bottom_offdist 2.0) wg_texh) wg_sca)
  )
  (if (< (pmdist xc_dirp xc_sel_pt) w_offd)
    (setq w_dim_pt (polar xc_sel_pt xc_ang (+ w_offd (/ 50.0 wg_sca))))
    (setq w_dim_pt xc_dirp)
  )
  (command ".donut"
	   0
	   (/ wg_dot_diameter 2.0 wg_sca)
	   xc_sel_pt
	   ""
  )
  (if (and (>= xc_ang 0) (<= xc_ang pi))
    (setq w_end_pt (polar w_dim_pt (- xc_ang (* 0.5 pi)) w_line_len))
    (setq w_end_pt (polar w_dim_pt (+ xc_ang (* 0.5 pi)) w_line_len))
  )
  (command "_.line" w_dim_pt w_end_pt "")
  (if (and (>= xc_ang 0) (<= xc_ang pi))
    (progn
      (setq w_txt_pt (polar w_dim_pt xc_ang (/ wg_bottom_offdist wg_sca))
	    w_txt_pt (polar w_txt_pt
			    (- xc_ang (* pi 0.5))
			    (/ wg_fspace_dist wg_sca)
		     )
      )
      (command "_.text"
	       w_txt_pt
	       (/ wg_texh wg_sca)
	       (rtod (- xc_ang (* pi 0.5)))
	       (nth 0 w_cd_list)
      )
    )
    (progn
      (setq w_txt_pt (polar w_dim_pt
			    (+ xc_ang pi)
			    (/ wg_bottom_offdist wg_sca)
		     )
	    w_txt_pt (polar w_txt_pt
			    (+ xc_ang (* pi 0.5))
			    (/ wg_fspace_dist wg_sca)
		     )
      )
      (command "_.text"
	       w_txt_pt
	       (/ wg_texh wg_sca)
	       (rtod (+ xc_ang (* pi 0.5)))
	       (nth 0 w_cd_list)
      )
    )
  )
  (setq	w_blen (length xc_iptb)
	w_ii   1
  )
  (while (< w_ii w_blen)
    (setq w_fpt	 (nth (- w_ii 1) xc_iptb)
	  w_bpt	 (nth w_ii xc_iptb)
	  w_mpt	 (midpt (p# w_fpt) (p# w_bpt))
	  w_offd (last w_bpt)
    )
    (setq w_dim_pt (polar w_dim_pt xc_ang w_off_dist))
    (command ".donut" 0 (/ wg_dot_diameter 2.0 wg_sca) w_mpt "")
    (if	(and (>= xc_ang 0) (<= xc_ang pi))
      (setq w_end_pt (polar w_dim_pt (- xc_ang (* 0.5 pi)) w_line_len))
      (setq w_end_pt (polar w_dim_pt (+ xc_ang (* 0.5 pi)) w_line_len))
    )
    (command "_.line" w_dim_pt w_end_pt "")
    (if	(and (>= xc_ang 0) (<= xc_ang pi))
      (progn
	(setq w_txt_pt (polar w_dim_pt xc_ang (/ wg_bottom_offdist wg_sca))
	      w_txt_pt (polar w_txt_pt
			      (- xc_ang (* pi 0.5))
			      (/ wg_fspace_dist wg_sca)
		       )
	)

	(command "_.text"
		 w_txt_pt
		 (/ wg_texh wg_sca)
		 (rtod (- xc_ang (* pi 0.5)))
		 (nth w_ii w_cd_list)
	)
      )
      (progn
	(setq w_txt_pt (polar w_dim_pt
			      (+ xc_ang pi)
			      (/ wg_bottom_offdist wg_sca)
		       )
	      w_txt_pt (polar w_txt_pt
			      (+ xc_ang (* pi 0.5))
			      (/ wg_fspace_dist wg_sca)
		       )
	)

	(command "_.text"
		 w_txt_pt
		 (/ wg_texh wg_sca)
		 (rtod (+ xc_ang (* pi 0.5)))
		 (nth w_ii w_cd_list)
	)
      )
    )
    (setq w_ii (1+ w_ii))
  )
  (command "_.line" xc_sel_pt w_dim_pt "")

)
;;; --------END-----------标注车道-----------END--------------

;;;--------BEGIN----------方位角标注---------BEGIN--------------
(defun dim_fwjbz (/		  w_glb		  w_ss
		  w_north_ang	  w_dim_set	  w_uctr
		  w_old_layer	  w_loop	  w_cc
		  w_ent		  w_sel_pt	  w_dim_ang
		  w_dirp	  w_dir_ang	  w_temp_pt
		  w_txt_ang	  w_dim_text	  w_txt_len
		  w_line_len	  w_dim_mp	  w_txt_mp
		  w_line_sp	  w_line_ep	  wg_arrow_len
		  wg_arrow_wid	  wg_semi_arrow_len
		  wg_semi_arrow_wid		  wg_short_line_len
		  wg_short_line_wid		  wg_fspace_dist
		  wg_bspace_dist  wg_bottom_offdist
		  wg_limit_extdist		  wg_dot_diameter
		  wg_sca	  wg_texh	  wg_txw
		 )
  (szload pub_save_var "wwpublic")
  (#ppas "drawroad")
  (szload $set_p_on_e "pppp")
  (pub_save_var)
  (setq w_glb '((8 . "AXIS") (0 . "LINE,*POLYLINE,ARC")))
  (setq w_ss (ssget "x" w_glb))
  (if  w_ss 
    (progn
;;;HY_GetNorthDirection()--真北方向与计算机零度方向的逆时针夹角

      (setq w_north_ang (HY_GetNorthDirection))
      (if (null (setq w_dim_set (DL_GetPrjVal "DIM_ALL_SET")))
	(setq w_dim_set
	       "3.0 0.25 3.0 0.15 2.0 0.25 0.5 0.5 0.5 1.0 1.0"
	)
      )
      (setq wg_arrow_len      (hy_get_dimset 0 w_dim_set)
	    wg_arrow_wid      (hy_get_dimset 1 w_dim_set)
	    wg_semi_arrow_len (hy_get_dimset 2 w_dim_set)
	    wg_semi_arrow_wid (hy_get_dimset 3 w_dim_set)
	    wg_short_line_len (hy_get_dimset 4 w_dim_set)
	    wg_short_line_wid (hy_get_dimset 5 w_dim_set)
	    wg_fspace_dist    (hy_get_dimset 6 w_dim_set)
	    wg_bspace_dist    (hy_get_dimset 7 w_dim_set)
	    wg_bottom_offdist (hy_get_dimset 8 w_dim_set)
	    wg_limit_extdist  (hy_get_dimset 9 w_dim_set)
	    wg_dot_diameter   (hy_get_dimset 10 w_dim_set)
      )
      (setq w_uctr  (HY_ClearUNDO)
	    wg_sca  (DL_GetDrawingFactor)
	    wg_texh (Dl_GetTextHeight)
	    wg_txw  (DL_GetDimPrec)
      )
      (styrem)
      (setq w_old_layer (getvar "clayer"))
      (DL_MakeLayer "pp-dl-bz")
      (setq w_loop t)
      (while w_loop
	(setq w_cc "\n回车退出 / 回退 U / 在道路中心线上点取标注点:")
	(setq w_ent
	       (HY_SelSingleEnt w_cc "LINE" "AXIS" nil "U")
	)
	(cond
	  ((null w_ent) (setq w_loop nil))
	  ((= w_ent "RETURN") (prompt "\n没选中指定实体!"))
	  ((= w_ent "U") ($undob w_uctr))
	  (t
	   (HY_UndoM)
;;;修正选择点
	   (setq w_sel_pt ($set_p_on_e w_ent)
		 w_ent	  (car w_ent)
	   )
;;;提取路宽，方向
	   (setq w_dim_ang (DrawRoad_GetRoadAng w_ent w_sel_pt))
;;;得到标注方向
	   (setq w_dirp (getpoint w_sel_pt "\n点示道路走向:"))
	   (if (null w_dirp)
	     (setq w_dir_ang w_dim_ang)
	     (setq w_temp_pt (polar w_sel_pt w_dim_ang 100.0)
		   w_dirp    ($qtyd1 w_dirp w_sel_pt w_temp_pt)
		   w_dir_ang (angle w_sel_pt w_dirp)
	     )
	   )
	   (setq w_dim_ang (+ w_dir_ang (* 0.5 pi)))
	   (setq w_txt_ang (rtod w_dir_ang))
	   (setq w_txt_ang (- w_txt_ang w_north_ang))
	   (setq w_txt_ang (- 360 w_txt_ang))
	   (setq w_txt_ang (rem w_txt_ang 360))
	   (setq w_ang_form (dl_getangform))
	   (setq w_ang_prec (dl_getangprec))
	   (setq w_dim_text (angtos (dtor w_txt_ang) w_ang_form w_ang_prec))
	   (if (= 0 w_ang_form)
           (setq w_dim_text (strcat w_dim_text "d"))
           )
	   (setq w_dim_text (strchth w_dim_text "d" "%%d"))
	   (setq w_txt_len ($txt_l w_dim_text (/ wg_texh wg_sca)))
	   (setq w_txt_len  (+ w_txt_len
			       (/ wg_fspace_dist wg_sca)
			       (/ wg_bspace_dist wg_sca)
			    )
		 w_line_len (+ w_txt_len (/ wg_semi_arrow_len wg_sca))
	   )
	   (setq w_dim_ang (rem w_dim_ang pi))
	   (setq w_dim_mp  (polar w_sel_pt
				  w_dim_ang
				  (/ wg_bottom_offdist wg_sca)
			   )
		 w_txt_mp  (polar w_dim_mp
				  w_dim_ang
				  (/ wg_bottom_offdist wg_sca)
			   )
		 w_line_sp (polar w_dim_mp
				  (+ w_dir_ang pi)
				  (* 0.5 w_line_len)
			   )
		 w_line_ep (polar w_dim_mp w_dir_ang (* 0.5 w_line_len))
	   )
	   (command "_.line" w_line_sp w_line_ep "")
	   (hy_semi_arrow
	     w_line_ep
	     (+ w_dir_ang pi)
	     w_dim_ang
	     wg_semi_arrow_len
	     wg_semi_arrow_wid
	     wg_sca
	   )
	   (command "_.text"
		    "j"
		    "bc"
		    w_txt_mp
		    (/ wg_texh wg_sca)
		    (rtod (- w_dim_ang (* 0.5 pi)))
		    w_dim_text
	   )
	  )
	)
      )
      (setvar "clayer" w_old_layer)
    )
    (prompt "\n 图中没有道路!")
  )
  (pub_re_var)
)
(defun strchth (str oldch newch / s len ch n)
  (setq s "")
  (if (/= str "")
    (progn
      (setq len	(strlen str)
	    n	1
      )
      (repeat len
	(setq ch (substr str n 1)
	      n	 (1+ n)
	)
	(if (= ch oldch)
	  (setq s (strcat s newch))
	  (setq s (strcat s ch))
	)
      )
    )
  )
  s
)
;;;--------END----------方位角标注---------END--------------

;;;----------BEGIN----------------道路切角标注----------BEGIN----------------
(defun dim_txttobz (txt txw / retv tex twid fixflag)
  (setq	tex  txt
	twid txw
  )
  (if (= (type tex) 'STR)
    (setq tex (read txt))
  )
  (cond
    ((null twid) (setq fixflag "T"))
    ((listp twid)
     (setq twid	   (car twid)
	   fixflag "T"
     )
    )
  )
  (cond
    ((= (type tex) 'INT) (setq retv (itoa tex)))
    ((= (type tex) 'REAL)
     (if (equal (fix (+ tex 0.001)) tex 0.01)
       (if fixflag
	 (setq retv (rtos tex 2 0))
	 (setq retv (rtos tex 2 twid))
       )
       (setq retv (rtos	tex
			2
			(if twid
			  twid
			  1
			)
		  )
       )
     )
    )
    (t
     ""
    )
  )
  retv
)

(defun #dw-anwz	(p1 p2 sc h dis ang / a1 a2 a anwz pw p ang1)
  (setq p1 (list (car p1) (cadr p1)))
  (setq p2 (list (car p2) (cadr p2)))
  (setq a1 (angle p1 p2))
  (setq a2 (angle p2 p1))
  (setq a (min a1 a2))

  (if (and (<= a (/ (* pi 2) 3.5))
	   (>= a 0.0)
      )
    (setq anwz a)
    (setq anwz (- a pi))
  )

  (setq p (polar p1 (angle p1 p2) (/ (distance (p# p1) (p# p2)) 2.0)))

  (setq pw (polar p (+ (/ pi 2) anwz) (/ dis sc)))
  (list pw (* 180.0 (/ anwz pi)))
)
(defun #len_pep	(pt ent ept / fhb p1)
  (setq	fhb (#len_pe pt ent)
	p1  (car (bg-ypp ent))
  )
  (if (equal ept p1 0.001)
    (setq fhb (append (list (cadr fhb) (car fhb)) (cddr fhb)))
  )
  fhb
)
(defun #len_pe(pt ent / entb r pc ans ane p1 p2 p l etype ptb)
  (setq pt (p# pt)
        entb (entget ent)
        etype (cdr (assoc 0 entb))
  )
  (cond
    ((= etype "LINE")
      (setq p1 (p# (cdr (assoc 10 entb)))
            p2 (p# (cdr (assoc 11 entb)))
            l  (distance pt p1)
            p  (distance p1 p2)
      ) 
      (if (<= l 1e-5) (setq l 0))
      (setq entb (list l (- p l) p p1 p2))
    )
    ((= etype "ARC")
      (setq r   (cdr (assoc 40 entb))
            pc  (cdr (assoc 10 entb))
            ans (cdr (assoc 50 entb))
            ane (cdr (assoc 51 entb))
            p1  (polar pc ans r)
            p2  (polar pc ane r)
            p   (* r (- ane ans))
      )
      (if (< p 0)
        (setq p (+ (* 2 pi r) p))  ;;;arc length
      )
      (cond
        ((equal pt p1 0.001)
          (setq entb (list 0 p p p1 p2))
        )
        ((equal pt p2 0.001)
          (setq entb (list p 0 p p1 p2))
        )
        (t
         (setq ane (angle pc pt))
         (if (< ane ans)
           (setq ane (+ ane pi pi))
         )
         (setq l (* r (- ane ans))) 
         (if (<= l 1e-5) (setq l 0))
         (setq entb (list l (- p l) p p1 p2))
        )
      )
    )
    ((wcmatch etype "*POLYLINE")
      (setq ptb (bg-ypp ent)
            p1 (last ptb)
            p2 (car ptb)
            p  (pl_len ent) 
      )
      (cond
        ((equal pt p1 0.001)
          (setq entb (list 0 p p p1 p2))
        )
        ((equal pt p2 0.001)
          (setq entb (list p 0 p p1 p2))
        )
        (t
          (command ".copy" ent "" '(0 0) '(0 0))
          (command ".break" (list (entlast) pt) p2)
          (setq l (pl_len (entlast))) 
          (if (<= l 1e-5) (setq l 0))
          (entdel (entlast))
          (setq entb (list l (- p l) p p1 p2))
        )
      )
    )
  )
  entb
)
(defun dim_act_qjbz (ent   sca	 texh  txh   toffldis	 bzfw  xz
		     /	   ptb	 p1    p2    lay   glb	 ent1  ent2
		     ipt   dist1 dist2 fhb   ang   pt	 pt1   pt2
		     len
		    )
  (setq	ptb  (bg-ypp ent)
	p1   (last ptb)
	p2   (car ptb)
	lay  (strcase(cdr (assoc 8 (entget ent))))
	glb  (list '(0 . "LINE,ARC") (cons 8 lay))
	ent1 (mentselps p1 bzfw glb ent)
  )
  (setq ent2 (mentselps p2 bzfw glb ent))
  (if (and ent1 ent2 (not (equal ent1 ent2)))
    (progn
      (if (= xz "JH")
	(HY_UndoM)
      )
      (HY_UndoM)
      (setvar "filletrad" 0)
      (command ".fillet" (list ent1 p1) (list ent2 p2))
      (setq ipt	  (car (ipt2e ent1 ent2))
	    dist1 (car (#len_pep p1 ent1 ipt))
	    dist2 (car (#len_pep p2 ent2 ipt))
	    fhb	  (#dw-anwz p1 p2 sca texh toffldis ang)
	    ang	  (angle ipt ($qtyd ipt ent))
	    pt	  (polar (midpt p1 p2) ang (+ toffldis (* 0.5 txh)))
      )
      (HY_UndoB)
      (if (equal dist1 dist2 0.01)
	(COMMAND "text"
		 "m"
		 pt
		 txh
		 (cadr fhb)
		 (strcat "Q" (dim_txttobz dist1 txw))
	)
	(progn
	  (setq	len   (* 0.5 (pmdist p1 p2))
		dist1 (strcat "Q" (dim_txttobz dist1 txw))
		dist2 (strcat "Q" (dim_txttobz dist2 txw))
		pt1   (polar
			pt
			(angle p2 p1)
			(- len
			   toffldis
			   (* 0.5 (caadr (textbox (list (cons 1 dist1)))))
			)
		      )
		pt2   (polar
			pt
			(angle p1 p2)
			(- len
			   toffldis
			   (* 0.5 (caadr (textbox (list (cons 1 dist2)))))
			)
		      )
	  )
	  (COMMAND "text"
		   "m"
		   pt1
		   txh
		   (cadr fhb)
		   dist1
	  )
	  (COMMAND "text"
		   "m"
		   pt2
		   txh
		   (cadr fhb)
		   dist2
	  )
	)
      )
    )
  )
)
(defun dim_qjbz	(/     glb   ss	   loop	 uctr  cc    ent   bzfw	 lay
		 sca   texh  toffldis	 txh   len   pt	   pt1	 pt2
		 dist1 dist2 p1	   p2	 ent1  ent2  ipt   fhb	 ang
		 txw
		)
  (szload pub_save_var "wwpublic")
  (pub_save_var)
  (HY_SV)
  (DL_MakeLayer "pp-dl-bz")
  (if (null $qtyd)
    (#ppls "pppp")
  )
  (styrem)
  (setq	uctr	 (HY_ClearUNDO)
	loop	 t
	sca	 (DL_GetDrawingFactor)
	texh	 (Dl_GetTextHeight)
	txh	 (/ texh sca)
	toffldis (/ 2.0 sca)
  )
  (setq	bzfw (*	0.707
		(/ (* 3.0 (getvar "viewsize"))
		   (* 0.5 (cadr (getvar "screensize")))
		)
	     )
  )
  (while loop
    (setq cc "\n回车退出 / 回退 U / 自动标注 Z / 选择道路人行道切角:")
    (setq ent (HY_SelSingleEnt cc "LINE" nil nil "U Z"))
    (cond
      ((null ent) (setq loop nil))
      ((= ent "RETURN") (prompt "\n没选中指定实体!"))
      ((= ent "U") ($undob uctr))
      ((= ent "Z")
       (setq ss	(ssget "X"
		       '((0 . "LINE")
			 (8 . "ROAD,XROAD")
			 (-4 . "<NOT")
			 (-3 ("DWAPP"))
			 (-4 . "NOT>")
			)
		)
       )
       (if (and ss (> (setq len (sslength ss)) 0))
	 (progn
	   (HY_UndoM)
	   (setq n 0)
	   (repeat len
	     (dim_act_qjbz
	       (ssname ss n)
	       sca
	       texh
	       txh
	       toffldis
	       bzfw
	       "ZD"
	     )
	     (setq n (1+ n))
	   )
	 )
       )
      )
      (t
       (dim_act_qjbz (car ent) sca texh txh toffldis bzfw "JH")
      )
    )
  )
  (HY_RV)
  (pub_re_var)
  (princ)
)
;;;-----------END---------------道路切角标注------------END--------------

;;;-----------BEGIN---------------道路切角修改------------BEGIN--------------
(defun dlqjxg (/ glb ss loop uctr cc ent bzfw lay)
  (szload pub_save_var "wwpublic")
  (pub_save_var)
  (HY_SV)
  (SETQ	GLB  (QUOTE ((0 . "LINE,ARC")
		    )
	     )
	ss   (ssget "x" glb)
	loop t
  )
  (if ss
    (progn
      (setq uctr (HY_ClearUNDO))
      (setq bzfw (* 0.707
		    (/ (* 3.0 (getvar "viewsize"))
		       (* 0.5 (cadr (getvar "screensize")))
		    )
		 )
      )
      (while loop
	(setq cc "\n回车退出 / 回退 U / 选择道路人行道切角:")
	(setq ent (HY_SelSingleEnt cc "LINE,ARC" nil nil "U"))
	(cond
	  ((null ent) (setq loop nil))
	  ((= ent "RETURN") (prompt "\n没选中指定实体!"))
	  ((= ent "U") ($undob uctr))
	  (t
	   (setq ent  (car ent)
		 ptb  (bg-ypp ent)
		 p1   (last ptb)
		 p2   (car ptb)
		 lay  (strcase(cdr (assoc 8 (entget ent))))
		 glb  (list '(0 . "LINE,ARC") (cons 8 lay))
		 ent1 (mentselps p1 bzfw glb ent)
	   )
	   (setq ent2 (mentselps p2 bzfw glb ent))
	   (if (and ent1 ent2)
	     (progn
	       (HY_UndoM)
	       (setvar "filletrad" 0)
	       (command ".fillet" (list ent1 p1) (list ent2 p2))
	       (setq ipt    (car (ipt2e ent1 ent2))
		     dist1  (car (#len_pep p1 ent1 ipt))
		     odist1 dist1
		     dist2  (car (#len_pep p2 ent2 ipt))
		     odist2 dist2
	       )
	       (grdraw p1 ipt 1 -1)
	       (initget 4)
	       (setq dis (getreal (strcat "\n虚线标记处切角长度一<"
					  (rtos dist1 2 2)
					  ">:"
				  )
			 )
	       )
	       (redraw)
	       (if dis
		 (setq dist1 dis)
	       )
	       (grdraw p2 ipt 1 -1)
	       (initget 4)
	       (prompt
		 (strcat "\n虚线标记处切角长度二为:" (rtos dist2 2 2))
	       )
	       (setq dis (getreal (strcat "\n虚线标记处切角长度二<"
					  (rtos dist1 2 2)
					  ">:"
				  )
			 )
	       )
	       (redraw)
	       (if dis
		 (setq dist2 dis)
		 (setq dist2 dist1)
	       )
	       (if (and	(equal dist1 odist1 0.01)
			(equal dist2 odist2 0.01)
		   )
		 (HY_UndoB)
		 (progn
		   (entdel ent)
		   (setq p1 (#lend_pos (list ent1 p1) dist1)
			 p2 (#lend_pos (list ent2 p2) dist2)
		   )
		   (command ".break" (list ent1 p1) ipt)
		   (command ".break" (list ent2 p2) ipt)
		   (command ".line" p1 p2 "")
		   (setq ent (entlast))
		   (HY_KZSJXZ ent "DWAPP" 8 lay)
		   (HY_KZSJXZ ent "DWAPP")
		 )
	       )
	     )
	   )
	  )
	)
      )
    )
  )
  (HY_RV)
  (pub_re_var)
  (princ)
)
;;;-----------END---------------道路切角修改------------END--------------




(defun dim_curve_para (/    w_ss	  len      i    w_ss1      w_ss2  w_ss_del
           applist   app      ent    w_csb  w_basep key  pt pickmode plwide layer
           arc_cp_lis cp arc_cp_list)
  (szload pub_save_var "wwpublic")
  (szload $arc_csb "pppp")
  (dl_arxload "pm_line")
  (pub_save_var)
  (setq pickmode (getvar "pickstyle"))
  (setq plwide (getvar "plinewid"))
  (setq layer (getvar "clayer"))
  (DL_MakeLayer "SZ-DIM-CURVE")
  (setvar "pickstyle" 1)
  (initget "X D")
  (setq key (getkword "\n <回车>自动标注 / 选取标注 X / 整路标注 D:"))
  (if (= key nil)
      (progn
	  (setq w_ss (ssget '((0 . "ARC,*POLYLINE") (8 . "AXIS"))))
	  (if w_ss
	     (dim_pqx w_ss)
	     (princ "\n已标注，如果要修改文字，请调用_.ddedit命令，或是 <文字--修改文字> 进行修改!")
	  );;;if
      );;;progn
      (progn
      	  (if (= key "D")
      	      (progn
      	      	(setq a t)
      	      	(while a
	         (setq ent (HY_SelSingleEnt "\n 请选择已经定义桩号的道路中心线实体:" "LINE,ARC,*POLYLINE" "AXIS" "DLZH_*" nil))
	        	(if (/= ent "RETURN")
				(setq a nil)
			)	
	        )
	        (if (/= ent nil)
	            (progn
		         (setq zhn (caadr (assoc -3 (entget (car ent) (list "DLZH_*")))))
		         (setq w_ss (ssget "x" (list (cons 0 "ARC,*POLYLINE")(cons 8 "AXIS") (list -3 (list zhn)))))
		         (dim_pqx w_ss)
		         (princ "\n已标注，如果要修改文字，请调用_.ddedit命令，或是 <文字--修改文字> 进行修改!")
	            )
	        )
      	      )
      	  )
      	  (if (= key "X")
      	      (progn
      	      	  (setq a t)
      	      	  (while a
      	      	       (setq ent (HY_SelSingleEnt "\n 请选择需标注的中心线曲线实体:" "ARC,*POLYLINE" "AXIS" nil nil))
      	      	       (if (/= ent "RETURN")
      	      	           (setq a nil)
      	      	       )
      	      	  )
	          (if (/= ent nil)
	              (progn
	                 (setq ent (car ent))
	                 (setq pt (getpoint "\n 请点取标注点:"))
	                 (if (null pt)
	                     (progn
	                        (setq w_csb (dim_curve ent))
	                        (setq w_dimb (car w_csb) w_basep (cadr w_csb))
	             			(dimqxtext ent w_basep w_dimb)
	                     )
	                     (progn
	                         (setq w_dimb (car (dim_curve ent)))
	                         (dimqxtext ent pt w_dimb)
	                      )	
	                  )
	                  (princ "\n已标注，如果要修改文字，请调用_.ddedit命令，或是 <文字--修改文字> 进行修改!")
	               );;;progn
	           );;if
      	      )
      	  )
      );;;progn
   );;;if
  (arxunload "pm_line")
  (setvar "clayer" layer)
  (setvar "plinewid" plwide)
  (setvar "pickstyle" pickmode)
  (pub_re_var)
  (princ)
)

(defun dim_pqx (w_ss / len i applist w_ss1 w_ss2 ent app arc_cp_list cp w_csb
                       w_csb w_dimb w_basep)
  (if w_ss
     (progn
        (setq len (sslength w_ss))
        (setq i 0)
        (setq applist nil)
        (setq w_ss1 (ssadd));;;单元曲线选择集
        (setq w_ss2 (ssadd));;;缓和曲线选择集
        (while (< i len)
              (setq ent (ssname w_ss i))
              (setq app (assoc -3 (entget ent (list "HYSZHHQX*"))))
              (if (= app nil)
                  (setq w_ss1 (ssadd ent w_ss1))
                  (progn
                    (setq app (car (cadr app)))
                    (if (= (member app applist) nil)
                        (setq w_ss2   (ssadd ent w_ss2)
                              applist (cons app applist)
                        )
                    )
                  )
              )
              (setq i (1+ i))
         )
         (setq  arc_cp_list nil)
         (if (/= w_ss1  nil)
        ;;;;单园曲线选择集
            (while (> (sslength w_ss1) 0)
	        (setq ent (ssname w_ss1 0))
                (ssdel ent w_ss1)
                (setq cp (cdr (assoc 10 (entget ent))))
                (if (not (member cp arc_cp_list))
                   (progn
                     (setq w_csb (dim_curve ent))
                     (if (/= w_csb nil)
                        (progn
                          (setq w_dimb (car w_csb) w_basep (cadr w_csb))
                          (dimqxtext ent w_basep w_dimb)
                          (setq arc_cp_list (cons cp arc_cp_list))
                        )
                     )
                   )
                )
            );;;while
          );;;if
      ;;;缓和曲线选择集
　　　　(if (/= w_ss2 nil)
           (progn
               (while (> (sslength w_ss2) 0)
                   (setq ent (ssname w_ss2 0))
                   (ssdel ent w_ss2)
                   (setq w_csb (dim_curve ent))
	                 (if (/= w_csb nil)
	                  (progn
	                     (setq w_dimb (car w_csb) w_basep (cadr w_csb))
	                     (dimqxtext ent w_basep w_dimb)

	                  )
	                 )
                );;;while
             );;;progn
         );;;if
     );;;progn
     (prompt "\n 图中没有道路弯道!")
  );;;if
)
;----h字高
;sc 总图比例
(defun dw-anwz2(p p1 p2 sc h / a1 a2 a pwz anwz p p1 p2)  
  (setq p1(list (car p1)(cadr p1)))
  (setq p2(list (car p2)(cadr p2)))
  (setq a1 (angle p1 p2))
  (setq a2 (angle p2 p1))
  (setq a (min a1 a2))
  
  (if (and (<= a (/ (* pi 2) 3.5)) 
        (>= a 0.0)
      ) 
    (setq anwz a)
    (setq anwz (- a pi))
  ) 
 
  (setq p(polar p anwz (/ h sc))) 

(list p (* 180.0 (/ anwz pi)))  
)  

(defun dw-dlh1 (c c1 zz h sc / a p1 p2 p pa ang1 ang2 textstyle)

  (if (= dd "")
    (setq c1 (polar c1 (angle c1 c) (/ (distance c c1) 2.0))
	  zz (list (car zz))
    )
  )

  (setq a (angle c1 c))
  (setq p1 (polar c1 (+ a (/ pi 2)) 1))
  (setq p2 (polar c1 (- a (/ pi 2)) 1))

  (setq pa (dw-anwz2 c1 p1 p2 sc h))
  (setq	p  (car pa)
	a1 (cadr pa)
  )


  (if (< a 0.0)
    (setq a (+ a (* 2 pi)))
  )
  (setq ang1 (- (/ pi 1.75) (/ pi 2)))
  (setq ang2 (+ pi ang1))


  (if (or (and (>= a 0.0) (<= a ang1))
	  (and (>= a ang2) (<= a (* 2 pi)))
      )
    (setq p (polar c1 a (/ (+ h 3.0) sc)))
    (setq p (polar c1 a (/ 3.0 sc)))
  )

  (setq a (angle c1 c))
  (setq p (polar p (+ a (/ pi 2)) (/ 3.0 sc)))
  (setq n 0)
  (setq textstyle (DL_GetTextStyle))
  (while (< n (length zz))

    (command "text" "s" textstyle p (/ h sc) a1 (nth n zz))
    (setq p (polar p a (/ (* h 1.8) sc)))
    (setq n (+ n 1))
  )


)

(defun dimqxtext (ent	 pt0     strlist    /
		  len	   llen    l_width  r_width  str
		  ang	      basept      lb_point rt_point lt_point rb_point
		  ss
		 )

;;;;ent 实体名 pt  pt2指定两点pt3参考点  strlist 字符列表

;;;;(draw_view ent pt1 pt2 pt3 strlist)

;;;偏移距离
  (setq	w_sca  (DL_GetDrawingFactor)
	;;w_txth (Dl_GetTextHeight)
	w_txth (/ (Dl_GetTextHeight) w_sca)
  )

  (setq dist (/ 50 w_sca))
  (setq len (length strlist))
  (if (> len 0)
    (progn

      (if (/= (rem len 2) 0)
	(setq llen (1+ (/ len 2)))
	(setq llen (/ len 2))
      )

      (setq count 0)
      (setq l_width -1)
	(setq r_width -1)
      (while (< count len)
	(setq str (nth count strlist))
	
	(setq str (&cal_tex_dis (list str w_txth)))
	
	(if (< l_width str)
	  (setq l_width str)
;;;;左侧文本的最长宽度
	)
	(setq count (1+ count ))
	(if (< count len)
	  (progn
	    (setq str (nth count strlist))
	    
	    (setq str (&cal_tex_dis (list str w_txth)))
	    (if	(< r_width str)
	      (setq r_width str)
	    )
;;;;左侧文本的最长宽度
	    (setq count (1+ count))

	  )
	)
      )

;;;;;;while(< count len)

      (setq basept
	     (list (- (car pt0) l_width (* 0.3 w_txth))
		   (- (cadr pt0) (* 1.3 w_txth))
	     )
      )
      (setq ss (ssadd))
      (setq count 0)
      (while (< count len)
	(setq str (nth count strlist))
	(if (/= str nil)
	  (progn
	    (hy_set0)
	    (command "_.text" "j" "bl" basept w_txth 0 str);;插入左侧文本
	    (hy_rv)
	    (setq nn (entlast))
	    (ssadd nn ss)
	  )
	)
	(setq basept
	       (list (+ (car basept) l_width (* 0.6 w_txth))
		     (cadr basept)
	       );;;移动插入点
	)
	(setq count (1+ count))
	(if (< count len)
	  (progn
	    (setq str (nth count strlist))
	    (if	(/= str nil)
	      (progn
	      	(hy_set0)
		(setq count (1+ count))	(command "_.text" "j" "bl" basept w_txth 0 str);;写入右侧文本
					(hy_rv)
					(setq nn (entlast))
					(ssadd nn ss)
	      );;progn
	    )
	  );;;progn
	)
	(setq basept
	       (list (- (car basept) l_width (* 0.6 w_txth))
		     (- (cadr basept) (* 1.3 w_txth))
	       )
	);;;移动插入点


      )
;;;while(< count len)
      ;;左上侧
      (setq lt_point (list (- (car pt0) l_width (* 0.5 w_txth)) (cadr pt0)))
      (setq lb_point (list (- (car pt0) l_width (* 0.5 w_txth))
			   (+ (cadr basept) (* 1.1 w_txth))
		     )
      );;;rectangle左下侧

;;右下侧
     (setq rb_point (list (+ (car pt0) (+ r_width (* 0.5 w_txth))) (+ (cadr basept) (* 1.1 w_txth))))
      (setq
	rt_point (list (+ (car pt0) (+ r_width (* 0.5 w_txth)))
		       (cadr pt0)
		 )
      );;;rectangle右上侧
      (hy_set0)
      (setvar "plinewid" 0.2)
      
      (command ".pline" lt_point lb_point rb_point rt_point "c")
      (hy_rv)
   ;;   (command "rectang" "w"  0.2   lb_point   rt_point)
      (setq nn (entlast))
      (ssadd nn ss)

      (setq lt_point (list (- (car lt_point) (* 0.3 w_txth))
			   (+ (cadr lt_point) (* 0.3 w_txth))
		     )
      )
      (setq rb_point (list (+ (car rb_point) (* 0.3 w_txth))
			   (- (cadr rb_point) (* 0.3 w_txth))
		     )
      )

      (setq lb_point (list (- (car lb_point) (* 0.3 w_txth))
			   (- (cadr lb_point) (* 0.3 w_txth))
		     )
      )
      (setq rt_point (list (+ (car rt_point) (* 0.3 w_txth))
			   (+ (cadr rt_point) (* 0.3 w_txth))
		     )
      )
      (hy_set0)
      (setvar "plinewid" 0.0)
      (command ".pline" lt_point lb_point rb_point rt_point "c")
      (hy_rv)
  ;;;    (command "rectang" "w"  0.0  lb_point  rt_point)
      (setq nn (entlast))
      (ssadd nn ss)
      (command "-group" "c" "*" "a" ss "")
      (setq ent1 (entget nn))
      (setq hand (assoc 5 ent1))
      (setq hand (cdr hand));;实体句柄
      (regapp "Dim-Cur")
      (HY_KZSJXZ ent "DIM-CUR" 1000 hand);;写入给定实体
    );;;;progn
  );;;;(if(<= len 0)
)