;**************同行文字合并工具******************
;***本工具出品于: Dcl-To-Lsp群(663130417); ***
;***作者:青春散场,不诉离殇!(QQ:702099480);***
;***时间: 2018年4月13日; ***
;************************************************
;;2019.12.10优化有时不能合并的bug,增加文字行排序!
(defun C:FV(/ delss endlst ent entlst entmlst entnow higy i n rowendlst rowlst ss startent_data)
(setvar "CMDECHO" 0)
(princ "\n选择合并文字:")
(if (setq ss (ssget '((0 . "*TEXT"))))
(progn
(setq entlst nil entmlst nil n 0)
(repeat (sslength ss)
(setq ent (ssname ss n))
(cond
((= (cdr (assoc 0 (entget ent))) "TEXT")
(setq entlst (cons (cons (cdr (assoc 10 (entget ent))) ent) entlst))
)
((= (cdr (assoc 0 (entget ent))) "MTEXT")
(setq entmlst (cons (cons (cdr (assoc 10 (entget ent))) ent) entmlst))
)
)
(setq n (+ n 1))
)
(if entlst
(progn
(setq entlst (vl-sort entlst '(lambda (x y) (< (cadar x) (cadar y)))) higy (cadaar entlst) n 0 entnow nil rowlst nil rowendlst nil)
(repeat (length entlst)
(setq entnow (nth n entlst))
(if (equal (cadar entnow) higy (/ (cdr (assoc 40 (entget (cdr entnow)))) 4.0))
(progn (setq rowlst (append rowlst (list entnow))))
(progn (setq rowendlst (append rowendlst (list rowlst)))
(setq rowlst (list entnow))
(setq higy (cadar entnow))
)
)
(setq n (+ n 1))
(if (= n (length entlst)) (setq rowendlst (append rowendlst (list rowlst))))
)
(command "_.UNDO" "be")
(setq n 0 endlst nil)
(repeat (length rowendlst)
(setq endlst (vl-sort (nth n rowendlst) '(lambda (x y) (< (caar x) (caar y)))))
(if (> (length endlst) 1)
(progn
(setq startent_data (entget (cdr (car endlst))) i 1)
(repeat (- (length endlst) 1)
(setq startent_data (subst (cons 1 (strcat (cdr (assoc 1 startent_data)) (cdr (assoc 1 (entget (cdr (nth i endlst))))))) (assoc 1 startent_data) startent_data))
(entmod startent_data)
(command "ERASE" (cdr (nth i endlst)) "")
(setq i (+ i 1))
)
)
)
(setq n (1+ n))
)
(command "_.UNDO" "e")
)
)
(if entmlst
(progn
(setq entmlst (vl-sort entmlst '(lambda (x y) (< (cadar x) (cadar y)))) higy (cadaar entmlst) n 0 entnow nil rowlst nil rowendlst nil)
(repeat (length entmlst)
(setq entnow (nth n entmlst))
(if (equal (cadar entnow) higy (/ (cdr (assoc 40 (entget (cdr entnow)))) 4.0))
(progn (setq rowlst (append rowlst (list entnow))))
(progn (setq rowendlst (append rowendlst (list rowlst)))
(setq rowlst (list entnow))
(setq higy (cadar entnow))
)
)
(setq n (+ n 1))
(if (= n (length entmlst)) (setq rowendlst (append rowendlst (list rowlst))))
)
(command "_.UNDO" "be")
(setq n 0 endlst nil)
(repeat (length rowendlst)
(setq endlst (vl-sort (nth n rowendlst) '(lambda (x y) (< (caar x) (caar y)))))
(if (> (length endlst) 1)
(progn
(setq startent_data (entget (cdr (car endlst))) i 1)
(repeat (- (length endlst) 1)
(setq startent_data (subst (cons 1 (strcat (cdr (assoc 1 startent_data)) (cdr (assoc 1 (entget (cdr (nth i endlst))))))) (assoc 1 startent_data) startent_data))
(entmod startent_data)
(command "ERASE" (cdr (nth i endlst)) "")
(setq i (+ i 1))
)
)
)
(setq n (1+ n))
)
(command "_.UNDO" "e")
)
)
)
)
(prin1)
)
(princ "\n 同行文字合并 快捷键:FV ")
(prin1)