;;;道路交通设施---道路交通标线
;;;wri yft 00.01.19

;;;双向两车道路面中心线(黄色虚线)
(defun ?dljtss_jtbx_sxlcdlmzxx
			       (/	 glb	  loop	   ss
				ss1	 p	  p1	   ent
				ss1	 k	  entb	   ename
				axis_pline	  dl_wid   old_plwid
				sel_sty	 olderr	  my_error 
  			       )
  (HY_Set0)
  (defun my_error (msg)
    (setq ss1 (ssget "x"
		     '(
		       (-4 . "<OR")
		       (-4 . "<AND")
		       (8 . "PP-TMP-SELDL");;;;;;;;;;20002/11
		       (-4 . "AND>")
		       (-4 . "<AND")
		       (0 . "INSERT")
		       (2 . "DL-C")
		       (-4 . "AND>")
		       (-4 . "OR>")
		      )
	      )
    )
    (if	ss1
      (command ".erase" ss1 "")
    )
    (HY_Set1)
  )

  (if (null $poly_test)
    (#ppls "pppp")
  )

;;  (setq	olderr	*error*
;;	*error*	my_error
;;  )
  (pusherr my_error)
  (setq old_plwid (getvar "plinewid"))
  (setq	glb    '((0 . "LINE,ARC,*POLYLINE") (8 . "AXIS"))
	bzfw   0.5
	dl_wid 0.15
	loop   t

  )
  (setq ss (ssget "x" glb))
  (while loop
    (initget 6 "X H E")
    (setq
      sel_sty (getpoint "\n退出E /选线X /绘制H /<回车选路中线>:")
    )

    (cond
      ((= sel_sty "E") (setq loop nil))
      ((= sel_sty "X")
       (setq axis_pline (?jtssbx_select_pline))
      )
      ((= sel_sty "H")
       (setq axis_pline (?jtssbx_draw_pline))
       (HY_Set0)
      )
      ((null sel_sty)
       (setq p (szdlseld glb bzfw "\n请选择道路中心线:"));;;2002-11-29 9:11王志宇修改
       (if (and p (/= p ""))
	 (progn
	   (setq p1 (cadr p))
	   (setq ent (car p)
		 ss1 (?search_axis ss ent)
	   )
	   (HY_SSRedraw ss1 3)

	   (setq axis_pline (?join_axis ss1 ent))
	 )
	 (if (null p)
	   (setq loop nil
		 axis_pline
		  nil
	   )
	 )
       )
      )
    )

    (if	(and axis_pline (entget axis_pline))
      (progn
	(if (null (tblsearch "ltype" "JTSS00"))
	  (command ".linetype" "l" "JTSS00" "DLJTXX.lin" "")
	  (progn
	  	;;;(command "layer" "S" "JTSS00" "")
	  	
	  )
	)
	
;;;pp-roadlay01--双向两车道路面中心线(黄色虚线)
	;;(HY_KZSJXZ axis_pline nil 8 "PP-ROADLAY01" 6 "JTSS00" 62 2)
	(HY_KZSJXZ axis_pline nil 8 "PP-ROADLAY01" 6 "JTSS00" 62 2)
	(command ".pedit" axis_pline "w" dl_wid "")
	(command ".chprop" axis_pline "" "s" 1 "")
	(setq axis_pline nil)
      )
    )
  )

;;;;  (setq *error* olderr)
  (clr_err)
  (setvar "plinewid" old_plwid)
  (HY_Set1)
  (princ)
)


;;;搜索连续的道路中心线
(defun ?search_axis (ss	     ent1    /	     ss1     ent2    ll
		     pt1     pt2     pt3     pt4     ptb     jd
		     ?join_axis_sub1
		    )
;;;	判断交叉口

  (defun ?join_axis_sub1 (p1 / s_ss s_flag)
    (setq s_flag t)
    (setq
      s_ss ($ptoe p1 '((0 . "LINE,ARC,*POLYLINE") (8 . "AXIS,ROAD")))
    )
    (if	(and s_ss (> (sslength s_ss) 2))
      (setq s_flag nil)
    )
    s_flag
  )

  (if ss
    (progn
      (if (null $ptoe)
	(#ppls "pppp")
      )
      (ssdel ent1 ss)
      (setq ss1 (ssadd))
      (ssadd ent1 ss1)
      (setq ptb	(bg-ypp ent1)
	    pt1	(p# (last ptb))
	    pt2	(p# (car ptb))
	    ll	0
	    jd	0.05
      )
      (while (setq ent2 (ssname ss ll))
	(setq ptb (bg-ypp ent2)
	      pt3 (p# (last ptb))
	      pt4 (p# (car ptb))
	)
	(cond
	  ((and (equal pt1 pt3 jd) (?join_axis_sub1 pt1))
	   (setq pt1 pt4)
	   (ssdel ent2 ss)
	   (ssadd ent2 ss1)
	   (setq ll -1)
	  )
	  ((and (equal pt1 pt4 jd) (?join_axis_sub1 pt1))
	   (setq pt1 pt3)
	   (ssdel ent2 ss)
	   (ssadd ent2 ss1)
	   (setq ll -1)
	  )
	  ((and (equal pt2 pt4 jd) (?join_axis_sub1 pt2))
	   (setq pt2 pt3)
	   (ssdel ent2 ss)
	   (ssadd ent2 ss1)
	   (setq ll -1)
	  )
	  ((and (equal pt2 pt3 jd) (?join_axis_sub1 pt2))
	   (setq pt2 pt4)
	   (ssdel ent2 ss)
	   (ssadd ent2 ss1)
	   (setq ll -1)
	  )
	)
	(setq ll (1+ ll))
      )
    )
  )

  ss1
)

;;;连接道路中线为POLYLINE;;;modi yft 00.02.28
(defun ?join_axis
		  (sel_ss sel_ent	/      n      len    ent
		   ent1	  ptb	 pt1	pt2    jd     p1     p2
		   start_pt	 ent_pt	psc    ss     loop   ins_ent
		   xx	  fil_sty	
		  )

  (if (= (strcase(cdr (assoc 8 (entget (ssname sel_ss 0))))) "ROAD")
    (setq fil_sty 1)
    (setq fil_sty 0)
  )

  (setq
    n	0
    ptb	(bg-ypp sel_ent)
    pt1	(p# (last ptb))
    pt2	(p# (car ptb))
    jd	0.05
    psc	(dw-psc 29.5)
  )
  (setvar "plinewid" 0)

  (HY_SV)
  (command ".copy" sel_ent "" '(0 0 0) '(0 0 0))
  (HY_RV)
  (setq	ent    (entlast)
	sel_ss (ssdel sel_ent sel_ss)
  )
  (if (> (sslength sel_ss) 0)
    (progn
      (command ".copy" sel_ss "" '(0 0 0) '(0 0 0))
      (setq sel_ss  (get_last ent)
	    sel_ent ent
      )
      (command "chprop" sel_ent sel_ss "" "la" "0" "")
    )
    (progn
      (setq sel_ent ent)
      (command "chprop" sel_ent "" "la" "0" "")
    )
  )
  (if (not (wcmatch (cdr (assoc 0 (entget sel_ent))) "*POLYLINE"))
    (command ".pedit" sel_ent "y" "")
  )
  (setq sel_ent (entlast))

  (if (> (sslength sel_ss) 0)
    (progn
      (while (setq ent (ssname sel_ss n))
	(setq ptb (bg-ypp ent)
	      p1  (p# (last ptb))
	      p2  (p# (car ptb))
	)
	(cond
	  ((equal pt1 p1 jd)
	   (ssdel ent sel_ss)
	   (if (equal pt1 p1 0.0)
	     (command ".pedit" sel_ent "j" ent "" "")
	     (progn
	       (HY_SV)
	       (command ".PLINE" pt1 p1 "")
	       (setq ent1 (entlast))
	       (command ".pedit" sel_ent "j" ent1 ent "" "")
	       (HY_RV)
	     )
	   )
	   (setq pt1 p2
		 n   -1
	   )
	  )
	  ((equal pt1 p2 jd)
	   (ssdel ent sel_ss)
	   (if (equal pt1 p2 0.0)
	     (command ".pedit" sel_ent "j" ent "" "")
	     (progn
	       (HY_SV)
	       (command ".PLINE" pt1 p2 "")
	       (setq ent1 (entlast))
	       (command ".pedit" sel_ent "j" ent1 ent "" "")
	       (HY_RV)
	     )
	   )
	   (setq pt1 p1
		 n   -1
	   )
	  )
	  ((equal pt2 p1 jd)
	   (ssdel ent sel_ss)
	   (if (equal pt2 p1 0.0)
	     (command ".pedit" sel_ent "j" ent "" "")
	     (progn
	       (HY_SV)
	       (command ".PLINE" pt2 p1 "")
	       (setq ent1 (entlast))
	       (command ".pedit" sel_ent "j" ent1 ent "" "")
	       (HY_RV)
	     )
	   )
	   (setq n   -1
		 pt2 p2
	   )
	  )
	  ((equal pt2 p2 jd)
	   (ssdel ent sel_ss)
	   (if (equal pt2 p2 0.0)
	     (command ".pedit" sel_ent "j" ent "" "")
	     (progn
	       (HY_SV)
	       (command ".PLINE" pt2 p2 "")
	       (setq ent1 (entlast))
	       (command ".pedit" sel_ent "j" ent1 ent "" "")
	       (HY_RV)
	     )
	   )
	   (setq pt2 p1
		 n   -1
	   )
	  )
	)
	(setq n (1+ n))
      )

      (if (> (sslength sel_ss) 0)
	(command ".erase" sel_ss "")
      )

    )
  )

  (HY_KZSJXZ sel_ent nil 8 "PP-TMP-SELDL")
;;;确定标线两端的位置	\
  (setq	ptb	 (bg-ypp sel_ent)
	start_pt (car ptb)
	end_pt	 (last ptb)

  )
  (foreach xx (list start_pt end_pt)
    (setq loop t)
    (HY_SV)
    (pan2v xx)
    (COMMAND "insert" (STRCAT (HY_GetInstallDir) "sys\\dl-c") xx PSC "" 0);;;;;????2002-11王志宇修改
    (setq ins_ent (entlast))
    (while loop

      (sa_osmode)
      (setvar "osmode" 544)
      (setq pt1 (getpoint "\n请点取该端标线的位置点:"))
      (re_osmode)
      (if (null pt1)
	(setq pt1 xx)
      )
      (setq
	ss ($ptoe pt1 '((0 . "*POLYLINE") (8 . "PP-TMP-SELDL")))
      )

      (if (and ss (= (sslength ss) 1) (equal sel_ent (ssname ss 0)))
	(progn
	  (setq loop nil)
	  (entdel ins_ent)

	  (if (= fil_sty 0)
	    (setq ss ($ptoe pt1 '((0 . "LINE,ARC") (8 . "AXIS"))))
	    (setq ss ($ptoe pt1 '((0 . "LINE,ARC") (8 . "ROAD"))))
	  )

	  (IF SS
	    (progn
	      (setq ins_ent (ssname ss 0))
	      (cond
		((equal (cdr (assoc 0 (entget ins_ent))) "LINE")
		 (setq p1 pt1
		       p1 (car (dw-lypp1 ins_ent p1))
		       p2 (polar p1
				 (+ (angle (cdr (assoc 10 (entget ins_ent)))
					   (cdr (assoc 11 (entget ins_ent)))
				    )
				    0.1
				 )
				 1
			  )
		 )
		 (zm2pt p1 p2)
		)
		((equal (cdr (assoc 0 (entget ins_ent))) "ARC")
		 (setq p1 pt1
		       p1 (car (dw-lypp1 ins_ent p1))
		       p2 (polar p1
				 (angle (cdr (assoc 10 (entget ins_ent))) p1)
				 1
			  )
		 )
		 (zm2pt p1 p2)
		)
	      )

	      (command ".line" p1 p2 "")
	      (setq ins_ent (entlast))
	      (command ".trim" ins_ent "" (list sel_ent xx) "")
	      (entdel ins_ent)
	    )
	  )
	)
	(princ "\n点取的不是该条路中线上的一点!")
      )
    )
    (HY_RV)
  )
  sel_ent
)

;;;车行道分界线(白色虚线)
;;; --- 快速路 ------------- sty=0
;;; --- 其他路 ------------- sty=1
;;;车行道边缘线(白色实线) -- sty=2
;;;专用车道线  (黄色虚线) -- sty=3
;;;禁止变换车道线	        -- sty=4
(defun ?dljtss_jtbx_cxdfjx
			   (sty	     /	      glb      loop
			    ss	     ss1      p	       p1
			    ent	     ss1      k	       entb
			    ename    axis_pline	       dl_wid
			    old_plwid	      dl_offset
			    cc_str   cc_str1  loop1    my_err
			    olderr		
			   )
  (HY_Set0)
  (defun my_err	(msg)
    (setq ss1 (ssget "x"
		     '(
		       (-4 . "<OR")
		       (-4 . "<AND")
		       (8 . "PP-TMP-SELDL")
		       (-4 . "AND>")
		       (-4 . "<AND")
		       (0 . "INSERT")
		       (2 . "DL-C")
		       (-4 . "AND>")
		       (-4 . "OR>")
		      )
	      )
    )
    (if	ss1
      (command ".erase" ss1 "")
    )
    (if	(and axis_pline (entget axis_pline))
      (entdel axis_pline)
    )
    (HY_Set1)
  )
  (if (null $poly_test)
    (#ppls "pppp")
  )
  (pusherr my_err)
;;  (setq	olderr	*error*
;;	*error*	my_err
;;  )
  (setq old_plwid (getvar "plinewid"))
  (setq	bzfw 0.5
	loop t
  )
  (cond
    ((= sty 3)
     (setq dl_wid 0.2)
    )
    (t
     (setq dl_wid 0.15)
    )
  )

  (if (= sty 2)
    (setq glb	  '((0 . "LINE,ARC,*POLYLINE") (8 . "AXIS,ROAD"))
	  cc_str  "\n退出E /选线X /绘制H /<回车选路中线或道路边线>:"
	  cc_str1 "\n请输入该分界线距边线的距离:"
    )
    (setq glb	  '((0 . "LINE,ARC,*POLYLINE") (8 . "AXIS"))
	  cc_str  "\n退出E /选线X /绘制H /<回车选路中线>:"
	  cc_str1 "\n请输入该分界线距中线的距离:"
    )
  )

  (setq ss (ssget "x" glb))

  (while loop
    (initget 6 "X H E")
    (setq
      sel_sty (getpoint cc_str)
    )

    (cond
      ((= sel_sty "E") (setq loop nil))
      ((= sel_sty "X")
       (setq axis_pline (?jtssbx_select_pline))
      )

      ((= sel_sty "H")
       (setq axis_pline (?jtssbx_draw_pline))
       (HY_Set0)
      )

      ((null sel_sty)

       (setq p (szdlseld glb bzfw "\n请选择起始道路线:"))
       (if (and p (/= p ""))
	 (progn
	   (setq p1 (cadr p))
	   (setq ent (car p)
		 ss1 (?search_axis ss ent)
	   )

	   (HY_SSRedraw ss1 3)

	   (setq axis_pline (?join_axis ss1 ent))

	 )
	 (if (null p)
	   (setq loop nil
		 axis_pline
		  nil
	   )
	 )
       )
      )
    )

    (if	(and axis_pline (entget axis_pline))
      (progn
	(cond
;;;车行道分界线(白色虚线);;;快速路
	  ((= sty 0)
	   (if (null (tblsearch "ltype" "JTSS00"))
	     (command ".linetype" "l" "JTSS00" "DLJTXX" "")
	   )
;;;pp-roadlay02---车行道分界线(白色虚线);;;快速路层
	   (HY_KZSJXZ axis_pline nil 8 "PP-ROADLAY02" 6 "JTSS00" 62 7)
	   (command ".chprop" axis_pline "" "s" 1.5 "")
	  )
;;;车行道分界线(白色虚线);;;其他路
	  ((= sty 1)
	   (if (null (tblsearch "ltype" "jtss01"))
	     (command ".linetype" "l" "JTSS01" "DLJTXX" "")
	   )
;;;pp-roadlay02---车行道分界线(白色虚线);;;其他路层
	   (HY_KZSJXZ axis_pline nil 8 "PP-ROADLAY02" 6 "JTSS01" 62 7)
	   (command ".chprop" axis_pline "" "s" 1 "")
	  )
;;;车行道边缘线(白色实线)
	  ((= sty 2)
;;;pp-roadlay03---车行道边缘线(白色实线)层
	   (HY_KZSJXZ axis_pline  nil	   8	       "PP-ROADLAY03"
		   6	       "Continuous"	       62
		   7
		  )
	  )
;;;专用车道线  (黄色虚线) -- sty=3
	  ((= sty 3)
	   (if (null (tblsearch "ltype" "JTSS02"))
	     (command ".linetype" "l" "JTSS02" "DLJTXX" "")
	   )

	   ;;;;2002-11-25 15:13由王志宇修改
	   ;;(DL_MakeLayer "PP-DL-JTBX")
	   (if (null (tblsearch "LAYER" "PP-DL-JTBX"))
	    (command "layer" "M" "PP-DL-JTBX" "")
	     (command "layer" "S" "PP-DL-JTBX" "")

	   )

	   ;;;;
	   (HY_KZSJXZ axis_pline nil 8 "PP-DL-JTBX" 6 "JTSS02" 62 2)
	   (command ".chprop" axis_pline "" "s" 4.0 "")
	  )
;;;禁止变换车道线	-- sty=4
	  ((= sty 4)
	  ;;;2002-11-25 15:14由王志宇修改
	   ;;;;(DL_MakeLayer "PP-DL-JTBX")
	   (if(null (tblsearch "LAYER" "PP-DL-JTBX"))
	      (command "layer" "M" "PP-DL-JTBX" "")
	     (command "layer" "S" "PP-DL-JTBX" "")
	   )
	   (HY_KZSJXZ axis_pline nil 8 "PP-DL-JTBX" 62 7)
	  )
	)

	(command ".pedit" axis_pline "w" dl_wid "")
	(if (null sel_sty)
	  (progn
	    (setq loop1 t)
	    (while loop1
	      (initget 6)
	      (if dl_offset
		(progn
		  (setq
		    k (getdist
			(strcat cc_str1 ":<" (rtos dl_offset 2 2) ">")
		      )
		  )
		  (if k
		    (setq dl_offset k)
		  )
		)
		(setq dl_offset (getdist cc_str1))
	      )
	      (if (and dl_offset (/= dl_offset 0))
		(progn
		  (setq k (cadr (bg-ypp axis_pline)))
		  (pan2v k)
		  (princ "\n回车结束 / 请确定偏移的方向:")
		  (HY_SV)
		  (setq k (getpoint k))
		  (if k
		    (command ".offset" dl_offset axis_pline k "")
		    (progn
		      (if (and axis_pline (entget axis_pline))
			(entdel axis_pline)
		      )
		      (setq axis_pline
			     nil
			    loop1 nil
		      )
		    )
		  )
		  (HY_RV)
		)
		(progn
		  (if (and axis_pline (entget axis_pline))
		    (entdel axis_pline)
		  )
		  (setq	axis_pline
			 nil
			loop1 nil
		  )
		)
	      )
	    )
	  )
	  (setq axis_pline nil)
	)
      )
    )
  )

;;;  (setq *error* olderr)
  (clr_err)
  (setvar "plinewid" old_plwid)
  (HY_Set1)
  (princ)
)


;;;选择线(line,*polyline,arc)
(defun ?jtssbx_select_pline (/ loop ent kk)

  (setq loop t)
  (while loop
    (setq
      ent (szdlseld '((0 . "LINE,ARC,*POLYLINE")) 0.05 "\n请选择线:")
    )
    (if	(and ent (listp ent))
      (progn
	(setq ent (car ent))
	(redraw ent 3)
	(initget 6 "Y N")
	(setq kk (getkword "\n是否为变虚的线(Y or N)<Y>:"))
	(redraw ent 4)
	(if (/= kk "N")
	  (progn
	    (if	(or (= (cdr (assoc 0 (entget ent))) "LINE")
		    (= (cdr (assoc 0 (entget ent))) "ARC")
		)
	      (progn
		(command ".pedit" ent "y" "")
		(setq ent (entlast))
	      )
	    )
	    (setq loop nil)
	  )
	)
      )
    )
    (if	(null ent)
      (setq loop nil)
    )
  )
  ent
)

;;;绘制复合线
(defun ?jtssbx_draw_pline (/ ent)

  (if (null #pline)
    (#ppls "pppp")
  )
  (setq ent (#pline "0"))


  ent
)

;;;道路交通设施---道路交通标线
;;;wri yft 00.01.19
;;;禁止超车线
;;;sty=1 双黄实线
;;;sty=2 黄虚实线
;;;sty=3 单黄实线
;;;sty=4 道路栏杆---high
;;;sty=5 道路栏杆---low
(defun ?dljtss_jtbx_jjccx (sty	     /	       glb	 loop
			   ss	     ss1       p	 p1
			   ent	     ss1       k	 k1
			   entb	     ename     axis_pline
			   dl_wid    old_plwid dl_offset cc_str
			   cc_str1   cc_str2   dis1	 dl_jjdist
			   my_err    olderr    fence_high
			   fence_width	       fence_size  
			  )
  (HY_Set0)
  (defun my_err	(msg)
    (setq ss1 (ssget "x"
		     '(
		       (-4 . "<OR")
		       (-4 . "<AND")
		       (8 . "PP-TMP-SELDL")
		       (-4 . "AND>")
		       (-4 . "<AND")
		       (0 . "INSERT")
		       (2 . "DL-C")
		       (-4 . "AND>")
		       (-4 . "OR>")
		      )
	      )
    )
    (if	ss1
      (command ".erase" ss1 "")
    )
    (if	(and axis_pline (entget axis_pline))
      (entdel axis_pline)
    )
    (HY_Set1)
  )
  (if (null $poly_test)
    (#ppls "pppp")
  )
  (setq old_plwid (getvar "plinewid"))
;;;  (setq	olderr	*error*
;;;	*error*	my_err
;;;  )
  (pusherr my_err)
  (setq	bzfw 0.5
	dl_wid 0.15
	dl_jjdist 0.3
	loop t
  )
  (setq	glb	'((0 . "LINE,ARC,*POLYLINE") (8 . "AXIS"))
	cc_str	"\n退出E /选线X /绘制H /<回车选路中线>:"
	cc_str1	"\n请输入该分界线距中线的距离<0>:"
	cc_str2	"\n退出E /设栏杆尺寸S /选线X /绘制H /<回车选路中线>:"
  )

  (while loop
    (setq ss (ssget "x" glb))
    (if	(or (= sty 4) (= sty 5))
      (progn
	(initget 6 "X H E S")
	(setq sel_sty (getpoint cc_str2))
      )
      (progn
	(initget 6 "X H E")
	(setq sel_sty (getpoint cc_str))
      )
    )

    (cond
      ((= sel_sty "E") (setq loop nil))
      ((= sel_sty "S")
       (setq fence_size (ppsgetcfg "FENCESIZE"))
       (if (or (null fence_size) (= fence_size ""))
	 (setq fence_size (list 1.2 5.0 0.7 5.0))
	 (setq fence_size (read fence_size))
       )
       (if (= sty 4)
	 (progn
	   (setq fence_high  (car fence_size)
		 fence_width (cadr fence_size)
	   )
	   (initget 6)
	   (setq fence_high
		  (getreal (strcat "\n 请输入栏杆的高度:<"
				   (rtos fence_high 2 1)
				   ">"
			   )
		  )
	   )
	   (if (null fence_high)
	     (setq fence_high (car fence_size))
	     (progn
	       (setq fence_size (lismod fence_size 0 fence_high))
	       (ppssetcfg "FENCESIZE" (listoa fence_size))
	     )
	   )
	   (setq fence_width
		  (getreal (strcat "\n 请输入栏杆的宽度:<"
				   (rtos fence_width 2 1)
				   ">"
			   )
		  )
	   )
	   (if (null fence_width)
	     (setq fence_width (cadr fence_size))
	     (progn
	       (setq fence_size (lismod fence_size 1 fence_width))
	       (ppssetcfg "FENCESIZE" (listoa fence_size))
	     )
	   )
	 )
	 (progn
	   (setq fence_high  (nth 2 fence_size)
		 fence_width (nth 3 fence_size)
	   )
	   (initget 6)
	   (setq fence_high
		  (getreal (strcat "\n 请输入栏杆的高度:<"
				   (rtos fence_high 2 1)
				   ">"
			   )
		  )
	   )
	   (if (null fence_high)
	     (setq fence_high (nth 2 fence_size))
	     (progn
	       (setq fence_size (lismod fence_size 2 fence_high))
	       (ppssetcfg "FENCESIZE" (listoa fence_size))
	     )
	   )
	   (setq fence_width
		  (getreal (strcat "\n 请输入栏杆的宽度:<"
				   (rtos fence_width 2 1)
				   ">"
			   )
		  )
	   )
	   (if (null fence_width)
	     (setq fence_width (nth 3 fence_size))
	     (progn
	       (setq fence_size (lismod fence_size 3 fence_width))
	       (ppssetcfg "FENCESIZE" (listoa fence_size))
	     )
	   )
	 )
       )
      )
      ((= sel_sty "X")
       (setq axis_pline (?jtssbx_select_pline))
      )
      ((= sel_sty "H")
       (setq axis_pline (?jtssbx_draw_pline))
       (HY_Set0)
      )
      ((null sel_sty)

       (setq p (szdlseld glb bzfw "\n请选择起始道路线:"))

       (if (and p (/= p ""))
	 (progn

	   (setq p1 (cadr p))
	   (setq ent (car p)
		 ss1 (?search_axis ss ent)
	   )

	   (HY_SSRedraw ss1 3)

	   (setq axis_pline (?join_axis ss1 ent))

	 )
	 (if (null p)
	   (setq loop nil
		 axis_pline
		  nil
	   )
	 )
       )
      )
    )
	
	;; 启用线型生成
	(command ".pedit" axis_pline "l" "on" "")
    (if	(and axis_pline (entget axis_pline))
      (progn
;;;dllay04--禁止超车线层
	(cond
;;;禁止超车线 ;;;sty=1 双黄实线, sty=3 单黄实线
	  ((or (= sty 1) (= sty 3))
	   (HY_KZSJXZ axis_pline  nil	   8	       "PP-ROADLAY04"
		   6	       "CONTINUOUS"	       62
		   2
		  )
	  )
;;;禁止超车线 ;;;sty=2 黄虚实线
	  ((= sty 2)
	   (initget 6 "D")
	   (setq
	     k (getkword "\n请选择虚线尺寸: 大尺寸D /<回车小尺寸>:")
	   )
	   (if (= k "D")
	     (progn
	       (if (null (tblsearch "ltype" "JTSS00"))
		 (command ".linetype" "l" "JTSS00" "DLJTXX" "")
	       )
	       (HY_KZSJXZ axis_pline nil	     8		"PP-ROADLAY04"
		       6	  "JTSS00"   62		2
		      )
	       (command ".chprop" axis_pline "" "s" 1.5 "")
	     )
	     (progn
	       (if (null (tblsearch "ltype" "JTSS01"))
		 (command ".linetype" "l" "JTSS01" "DLJTXX" "")
	       )
	       (HY_KZSJXZ axis_pline nil	     8		"PP-ROADLAY04"
		       6	  "JTSS01"   62		2
		      )
	       (command ".chprop" axis_pline "" "s" 1 "")
	     )
	   )
	  )
	  ((or (= sty 4) (= sty 5))
	   (if (null (tblsearch "ltype" "FENCELINE1"))
	     (command ".linetype" "l" "FENCELINE1" "ACADISO" "")
	   )
	   ;;(DL_MakeLayer "PP-DL-FENCE")

	   ;;;;2002-11-25 15:13由王志宇修
	   (if (null (tblsearch "LAYER" "PP-DL-JTBX"))
	    (command "layer" "M" "PP-DL-JTBX" "")
	     (command "layer" "S" "PP-DL-JTBX" "")

	   )

	   ;;;;
	   (setq fence_lay "PP-DL-FENCE")

	   (setq fence_size (ppsgetcfg "FENCESIZE"))
	   (if (or (null fence_size) (= fence_size ""))
	     (setq fence_size (list 1.2 5.0 0.7 5.0))
	     (setq fence_size (read fence_size))
	   )
	   (if (= sty 4)
	     (progn
	       (setq fence_high	 (car fence_size)
		     fence_width (cadr fence_size)
	       )
	       (HY_KZSJXZ axis_pline
		       "FENCEFILE"
		       8
		       fence_lay
		       6
		       "fenceline1"
		       1010
		       (list fence_high fence_width 0.0)

	       )
	     )
	     (progn
	       (setq fence_high	 (nth 2 fence_size)
		     fence_width (nth 3 fence_size)
	       )
	       (HY_KZSJXZ axis_pline
		       "FENCEFILE"
		       8
		       fence_lay
		       6
		       "fenceline1"
		       62
		       2
		       1010
		       (list fence_high fence_width 0.0)
	       )
	     )
	   )

	   (command ".chprop" axis_pline "" "s" 0.25 "")
	  )
	)

	(HY_SV)
	(if (and (/= sty 4) (/= sty 5))
	  (command ".pedit" axis_pline "w" dl_wid "")
	  (command ".pedit" axis_pline "w" 0 "")
	)
	(if (null sel_sty)
	  (progn
	    (initget 4)
	    (setq dl_offset (getdist cc_str1))
	    (if	(and dl_offset (/= dl_offset 0.0))
	      (progn
		(setq k (cadr (bg-ypp axis_pline)))
		(pan2v k)
		(princ "\n 请确定偏移的方向:")
		(initget 7)
		(setq k (getpoint k))
	      )
	      (setq dl_offset 0
		    k 3
	      )
	    )
	  )
	  (setq	dl_offset 0
		k 3
	  )
	)

	(cond
	  ((= sty 1)
	   (setq dis1 (+ dl_offset (/ (+ dl_jjdist dl_wid) 2.0)))
	   (command ".offset" dis1 axis_pline k "")
	   (setq k  (entlast)
		 k  (bg-ypp k)
		 k1 (bg-ypp axis_pline)
	   )
	   (setq k (polar (car k)
			  (angle (car k) (car k1))
			  (+ dl_jjdist dl_wid)
		   )
	   )
	   (command ".offset" "t" axis_pline k "")
	   (entdel axis_pline)
	  )
	  ((= sty 2)
	   (setq dis1 (+ dl_offset (/ (+ dl_jjdist dl_wid) 2.0)))

	   (command ".offset" dis1 axis_pline k "")
	   (setq k  (entlast)
		 k  (bg-ypp k)
		 k1 (bg-ypp axis_pline)
	   )
	   (setq k (polar (car k)
			  (angle (car k) (car k1))
			  (+ dl_jjdist dl_wid)
		   )
	   )
	   (command ".offset" "t" axis_pline k "")
	   (entdel axis_pline)
	   (setq k t)
	   (while k
	     (setq k1 (szdlseld '((8 . "PP-ROADLAY04"))
			       0.01
			       "\n请选择转为实线的标线:"
		      )
	     )
	     (if (and k1 (listp k1))
	       (progn
		 (setq k1 (car k1))
		 (redraw k1 3)
		 (initget 6 "Y N")
		 (setq dis1 (getkword "\n是否为变虚的线(Y or N)<Y>:"))
		 (if (/= dis1 "N")
		   (progn
		     (setq k nil)
		     (redraw k1 4)
		     (HY_KZSJXZ k1 nil 6 "Continuous")
		   )
		   (redraw k1 4)
		 )
	       )
	     )
	   )
	  )
	  ((= sty 3)
	  (if ( > dl_offset 0 )
	   (progn
	   (command ".offset" dl_offset axis_pline k "")
	   (entdel axis_pline)
	   (setq axis_pline nil)
	  )
	  )
	   
	   
	  )
	  ((and	(or (= sty 4) (= sty 5))
		(null sel_sty)
		dl_offset
		(/= dl_offset 0.0)
	   )
	   (command ".offset" dl_offset axis_pline k "")
	   (entdel axis_pline)
	   (setq axis_pline nil)
	  )
	)

	(HY_RV)
      )

    )
  )

  ;;(setq *error* olderr)
  (clr_err)
  (setvar "plinewid" old_plwid)
  (HY_Set1)
  (princ)
)


;;;连接栏杆的漫游图象文件
(defun ?dl_fence_join_txwj
       (/ fence_ss filename n len ent fence_high fence_width  my_error)

  (HY_Set0)
  (defun my_error(msg)
      (HY_Set1)
    )
;;  (setq error *error*)
;;  (setq *error* my_error)
  (pusherr my_error)
  (princ "\n回车退出 /<请选择道路栏杆>:")
  (setq	fence_ss
	 (ssget	'((0 . "*POLYLINE") (8 . "PP-DL-FENCE"))
	 )
  )
  (if fence_ss
    (progn
      (setq
	filename (getfiled "请选择这些栏杆的漫游图象文件" (strcat (HY_GetInstallDir) "bmp\\") "bmp" 8)
      )
      (if (and filename (setq filename (findfile filename)))
	(progn
	  (setq len (strlen (strcat (HY_GetInstallDir) "bmp\\"))
		filename (substr filename (1+ len))
	  )

	  (initget 6)
	  (setq fence_high (getreal "\n 请输入栏杆的高度:<1.0>"))
	  (if (null fence_high)
	    (setq fence_high 1.0)
	  )
	  (setq fence_width (getreal "\n 请输入栏杆的宽度:<5.0>"))
	  (if (null fence_width)
	    (setq fence_width 5.0)
	  )
	  (setq	n   0
		len (sslength fence_ss)
	  )
	  (while (< n len)
	    (setq ent (ssname fence_ss n))
	    (HY_KZSJXZ ent
		    "fencefile"
		    1000
		    filename
		    1010
		    (list fence_high fence_width 0.0)
	    )
	    (setq n (1+ n))
	  )
	)
      )
    )
  )
  (HY_Set1)
 ;;; (setq *error* error)
  (clr_err)
  (princ)
)
;;;以下函数于2002年11月由王志宇添加
(defun szdlseld(glb sca cc / xh ssz ss p1 p2 ent ns ns1 enb2 wb p0 sca my_error )
;;  (defun my_error(msg)
;;    (setq *error* error)
;;    )
;;  (setq error *error*)
;;  (setq *error* my_error)
	(sa_osmode)
  (command "osnap" "nea")
  (setq enb2 (entsel cc))
  (if (= (type enb2) 'LIST)
    (progn

      (setq sca	(* 0.707
		   (/ (* (getvar "pickbox") (getvar "viewsize"))
		      (* 0.5 (cadr (getvar "screensize")))
		   )
		)
      )
      (setq p0 (cadr enb2)
	    p2 (polar p0 (* pi 0.25) sca)
	    p1 (polar p0 (* pi 1.25) sca)
      )
      (setq ss (ssget "C" p1 p2 glb))

      (if (= ss nil)
	(progn
	  (prompt "\n没选中指定实体,重选!")
	  (setq enb2 "")
	)
	(progn
	  (setq	ent (ssname ss 0)
		wb  (entget ent)
	  )
	  (if (= (cdr (assoc 0 wb)) "LINE")
	    (setq p1 (cdr (assoc 10 wb))
		  p2 (cdr (assoc 11 wb))
		  p0 (interss p1
			      p2
			      p0
			      (polar p0 (+ (angle p1 p2) (* pi 0.5)) 1026.0)
			      nil
		     )
	    )
	  )
	  (setq enb2 (list ent p0))
	)
      )
    )
  )
  (re_osmode)
 ;;; (setq *error* error)
  enb2
)
(princ)

