(defun text_join( / xh enb2 ent wb_ent lay_str str_tmp style_str glb_str ss_str ns ns1
       h_text ss_select dist_join zjz_var lay_chg2_char
       )
 (setq xh t)
 (while xh
  (setq enb2 (gpsseld '((0 . "TEXT")) "\n 回车或空选退出 /选择一个要转换的文字样例:" nil) )
  (cond
   ((= enb2 t) t)
   ((= enb2 nil) (setq xh nil) )
   (t
    (setq ent (car enb2) )
    (setq wb_ent (entget ent) lay_str (cdr (assoc 8 wb_ent))
          str_tmp (cdr (assoc 1 wb_ent)) style_str (cdr (assoc 7 wb_ent)) h_text (cdr (assoc 40 wb_ent))
    )
    (setq type_strtmp (strtype str_tmp) )
    (if (/= type_strtmp "INT") (progn
      (prompt "\n 没有选择数字，重选！")
     ) (progn
      (setq glb_str (list '(0 . "TEXT") (cons 8 lay_str) (cons 7 style_str) (cons 40 h_text)) )
      (setq lay_chg2_char (strcat lay_str "_tmp") )
      (setq xh nil)
    ))
   )
  )    ;;end of cond
 )    ;;end of while xh
 (if glb_str (progn
   (setq dist_join (* h_text 0.5) )
   (initget 6)
   (setq zjz_var (getreal (strcat "\n 输入可识别数字的最大间距<" (rtos dist_join 2 1) ">:")) )
   (if zjz_var (progn
     (setq dist_join zjz_var)
   ))
   (prompt "\n 选择要合并的标高数字:")
   (setq ss_str (ssget glb_str) )
   (if ss_str (progn
     (command "layer" "m" lay_chg2_char "c" 6 "" "")
     (setq ss_select (ssadd) )
     (setq ns (sslength ss_str) ns1 0)
     (repeat ns
      (setq ent (ssname ss_str ns1) )
      (if (entget ent) (progn
        (text_join_2 ent ss_str glb_str dist_join)      
      ))    ;;end of if (entget ent)
      (ssadd ent ss_select)
      (setq ns1 (+ ns1 1))
     )    ;;end of repeat
   ))    ;;end of if ss_str
 ))     ;;end of if glb_str
 (tocom)
 (princ)
)    ;;end of defun
;;
;;
(defun text_join_2 (ent ss_str glb_str dist_join / wb_ent pt_bl ang_text str_text pt_list pt_tr dist_text h_text
       pt_br ss_del xh_bz pt_bl_tmp list_str pt_tl_tmp ss_text ns ns1 ent_tmp str_tmp pt_tmp ang2_text
       ang_tmp dist_tmp wb_tmp pt_br_tmp pt_text_std    )
 (setq wb_ent (entget ent) pt_bl (cdr (assoc 10 wb_ent)) ang_text (cdr (assoc 50 wb_ent))
       str_text (cdr (assoc 1 wb_ent))
 )
 ;;(setq ss_select (ssadd) )
 ;;(setq glb_str (cons (cons 1 ang_text) glb_str) )
 (setq pt_list (textbox wb_ent) pt_tr (cadr pt_list) dist_text (car pt_tr) h_text (cadr pt_tr) )
 (setq pt_br (polar pt_bl ang_text (car pt_tr)) )
 (setq ss_del (ssadd) )
 (setq pt_text_std pt_bl)
 (setq xh_bz t pt_bl_tmp pt_bl list_str nil)
 (while xh_bz
;;  (setq pt_tl_tmp (polar (polar pt_bl_tmp (+ ang_text pi) dist_text) (+ ang_text (* pi 0.5)) h_text) )
  (setq pt_tl_tmp (polar (polar pt_bl_tmp (+ ang_text pi) dist_join) (+ ang_text (* pi 0.5)) h_text) )
  (&view_ptb (list pt_bl_tmp pt_tl_tmp))
;(&vec_cir pt_bl_tmp 32 23 6 t)
;(&vec_cir pt_tl_tmp 32 23 4 t)
;(print str_text)
;(getpoint "\n YYYY")
;(redraw)
  (setq ss_text (ssget "C" pt_tl_tmp pt_bl_tmp glb_str) )
  (if (= ss_text nil) (progn
    (setq xh_bz nil)
   ) (progn
    (ssdel ent ss_text )
    (if (or (= ss_text nil) (= (sslength ss_text) 0)) (progn
      (setq xh_bz nil)
     ) (progn
	    (setq ns (sslength ss_text) ns1 0 list_str nil)
      (repeat ns
       (setq ent_tmp (ssname ss_text ns1) wb_ent (entget ent_tmp) str_tmp (cdr (assoc 1 wb_ent)) )
       (setq pt_tmp (cdr (assoc 10 wb_ent)) ang2_text (cdr (assoc 50 wb_ent)) ang_tmp (angle pt_tmp pt_bl_tmp) )
			 (setq pt_list (textbox wb_ent) pt_tr (cadr pt_list) dist_tmp (car pt_tr) )
;(print (list str_tmp (eq_ang ang_text ang2_text) (eq_ang ang_tmp ang_text)
;                (< (pmdist (polar pt_tmp ang2_text dist_tmp) pt_bl_tmp) dist_join)
;                (= (strlen str_tmp) 1)
;                (= (ssmemb ent_tmp ss_select) nil) (ssmemb ent_tmp ss_str)
;                (pmdist (polar pt_tmp ang2_text dist_tmp) pt_bl_tmp) dist_join
;       )
;)
;(getpoint "\n UUUUccccsssssss") 
       (if (and (eq_ang ang_text ang2_text) (eq_ang ang_tmp ang_text)
                (< (pmdist (polar pt_tmp ang2_text dist_tmp) pt_bl_tmp) dist_join)
                (= (strlen str_tmp) 1)
                (= (ssmemb ent_tmp ss_select) nil) (ssmemb ent_tmp ss_str)
           )
        (progn
         (setq list_str (cons (list (list str_tmp ent_tmp pt_tmp) (pmdist pt_tmp pt_bl)) list_str) )
       ))
       (setq ns1 (+ ns1 1) )
      )
      (if (= list_str nil) (progn
        (setq xh_bz nil)
       ) (progn
        (setq list_str (lispx list_str) )
        (setq wb_tmp (caar list_str) str_tmp (car wb_tmp) ent_tmp (cadr wb_tmp) pt_tmp (caddr wb_tmp) )
        (if (or (= str_tmp ".") (= str_tmp "-") (= str_tmp "+") (= (strtype str_tmp) "INT"))
         (progn
;(print str_tmp)
          (setq str_text (strcat str_tmp str_text) pt_text_std (caddr wb_tmp) )
          (ssadd ent_tmp ss_del)
          (ssadd ent_tmp ss_select)
          (setq pt_bl_tmp pt_tmp)
        ))       
      ))    ;;end of if list_str      
    ))      ;;end of if ns > 0
  ))    ;;end of if ss_text
 )    ;;end of while xh_bz
 (setq xh_bz t pt_br_tmp pt_br )
 (while xh_bz
  (setq pt_tr_tmp (polar (polar pt_br_tmp ang_text dist_join) (+ ang_text (* pi 0.5)) h_text) )
  (&view_ptb (list pt_br_tmp pt_tr_tmp))
;(&vec_cir pt_br_tmp 32 23 6 t)
;(&vec_cir pt_tr_tmp 32 23 4 t)
;(print str_text)
;(getpoint "\n YYYYeeeeee")
;(redraw)
  (setq ss_text (ssget "C" pt_br_tmp pt_tr_tmp glb_str) )
  (if (= ss_text nil) (progn
    (setq xh_bz nil)
   ) (progn
    (ssdel ent ss_text)
    (if (or (= ss_text nil) (= (sslength ss_text) 0)) (progn
      (setq xh_bz nil)
     ) (progn
	    (setq ns (sslength ss_text) ns1 0 list_str nil)
      (repeat ns
       (setq ent_tmp (ssname ss_text ns1) wb_ent (entget ent_tmp) str_tmp (cdr (assoc 1 wb_ent)) )
       (setq pt_tmp (cdr (assoc 10 wb_ent))  ang2_text (cdr (assoc 50 wb_ent)) )
       (setq ang_tmp (angle pt_br_tmp pt_tmp) )
			 (setq pt_list (textbox wb_ent) pt_tr (cadr pt_list) dist_tmp (car pt_tr) )
;(print (list str_tmp (eq_ang ang_text ang2_text) (eq_ang ang_tmp ang_text)
;                (< (pmdist pt_tmp pt_br_tmp) dist_join)
;                (= (strlen str_tmp) 1)
;                (= (ssmemb ent_tmp ss_select) nil) (ssmemb ent_tmp ss_str)
;       )
;)
;(getpoint "\n UUUUcccc") 
       (if (and (eq_ang ang_text ang2_text) (eq_ang ang_tmp ang_text)
                (< (pmdist pt_tmp pt_br_tmp) dist_join)
                (= (strlen str_tmp) 1)
                (= (ssmemb ent_tmp ss_select) nil) (ssmemb ent_tmp ss_str)
           )
        (progn
         (setq list_str (cons (list (list str_tmp ent_tmp pt_tmp dist_tmp) (pmdist pt_br_tmp pt_tmp)) list_str) )
       ))
       (setq ns1 (+ ns1 1) )
      )
      (if (= list_str nil) (progn
        (setq xh_bz nil)
       ) (progn
        (setq list_str (lispx list_str) )
        (setq wb_tmp (caar list_str) str_tmp (car wb_tmp) ent_tmp (cadr wb_tmp)
              pt_tmp (caddr wb_tmp)  dist_tmp (nth 3 wb_tmp)
        )
;(print (list str_tmp str_text ))
        (if (or (= str_tmp ".") (= str_tmp "-") (= str_tmp "+") (= (strtype str_tmp) "INT"))
         (progn
          (setq str_text (strcat str_text str_tmp) )
          (ssadd ent_tmp ss_del)
          (ssadd ent_tmp ss_select)
          (setq pt_br_tmp (polar pt_tmp ang_text dist_tmp) )
        ))       
      ))    ;;end of if list_str      
    ))      ;;end of if ns > 0
  ))    ;;end of if ss_text
 )    ;;end of while xh_bz
 (if (and ss_del (> (sslength ss_del) 0)) (progn
   ;;(command "erase" ss_del "")
   (ssadd ent ss_del)
   (command "copy" ent "" '(0 0 0) '(0 0 0) )
   (setq ent_new (entlast) )
   (command "change" ss_del "" "p" "la" lay_chg2_char "c" 6 "")
   (hy_kzsjxz ent_new nil 1 str_text 10 pt_text_std)
 ))
)    ;;end of defun
;;
;;
;检查字符串内数据类型
(defun strtype(strab /  strtmp intn intfpos intpntpos strf strpnt blnstr intn2 inttmp)
 (setq intn 0 intfpos nil intpntpos nil)
 (setq strab (scanb strab) strf "" strpnt "")
 (cond
  ((= strab "")
   (setq strtmp "STRNULL")
  )
  ((or (= strab ".") (= strab "-")) (setq strtmp "STR"))
  (t
   (setq intn2 1 ns (strlen strab))
   (while (<= intn2 ns)
    (setq inttmp (ascii (substr strab intn2 1)) )
    (cond
     ((or (= inttmp 43) (= inttmp 45))
      (setq strf (strcat strf (substr strab intn2 1)) )
      (setq intfpos (cons intn2 intfpos))
     )
     ((= inttmp 46)
      (setq strpnt (strcat strpnt (substr strab intn2 1)) )
      (setq intpntpos (cons intn2 intpntpos))
     )
     ((or (< inttmp 48) (> inttmp 57))
      (setq strtmp "STR" intn2 (+ ns 1))
     )
    )
    (setq intn2 (+ intn2 1))
   )    ;end of while intn2
   (setq intfpos (reverse intfpos) intpntpos (reverse intpntpos))
   (if (or (= strtmp "STR") (> (strlen strf) 1) (> (strlen strpnt) 1)
           (and (= (length intfpos) 1) (> (car intfpos) 1))
           (and (= (length intfpos) 1) (= (length intpntpos) 1) (< (car intpntpos) (car intfpos)))
       )
     (setq strtmp "STR")
     (if (= strpnt "")
       (setq strtmp "INT")
       (setq strtmp "REAL")
     )
   )     ;end of if or
  )
 )    ;end cond strab
 strtmp
)    ;end of defun
;
