<b>
</b>对齐文字
(defun C:TX (/ m e1 ent en en1 yesno ptb gop next
temp1 temp2 temp3 ptn total count)
(setq m:err *error* *error* *merr*)
(setvar "cmdecho" 0)
(command "UNDO" "G")
(setq e1 (entsel "\n选择基准文字:"))
(if (= e1 nil)(princ) (progn
(setq ent (entget (car e1)))
(setq en (cdr (assoc '0 ent )))
(if (/= en "TEXT") (princ "\n---所选图元不是文字---")
(progn
(setq en1 (cdr (assoc '-1 (entget (car e1)))))
(redraw en1 3)
(initget 128 "X Y")
(setq yesno (getkword "\n水平对齐(Y) / 垂直对齐(<X>) ? "))
(if (or (= yesno "X") (= yesno nil))
(setq ptb (cadr (assoc '10 ent)))
(setq ptb (car (cddr (assoc '10 ent)))))
(setq gop (ssget) count 0 total 0)
(redraw en1 4)
(repeat (sslength gop)
(setq next (entget (ssname gop count)))
(if (= (cdr (assoc 0 next)) "TEXT") (progn
(setq temp1 (car (cdr (assoc 10 next)))
temp2 (cadr (cdr (assoc 10 next)))
temp3 (caddr (cdr (assoc 10 next))))
(if (or (= yesno "X") (= yesno nil))
(setq ptn (list ptb temp2 temp3))
(setq ptn (list temp1 ptb temp3)) )
(setq next (subst (cons 10 ptn)(assoc 10 next) next))
(entmod next)
(setq total (1+ total))
))
(setq count (1+ count))
)
(princ "\n共有 ")(princ total)(princ " 个文字串被改变")
))
))
(command "UNDO" "E")
(print) ) |