;只选择文本
(ssget '((0 . "text")))
;只选择文本
(ssget (list (cons 0  "text")))
;只选取含数字的文本
(ssget '((1 . "*[0-9]*")))
;只选取含数字的文本
(ssget '((1 . "*#*")))
;只选取数字文本
(ssget '((0 . "TEXT") (1 . "~*[~`--9]*")))
;获得文本的定义数据
(entget (car (nentsel "请选择文本")))
;获得文本内容
(cdr (assoc 1 (entget (car (nentsel)))))
;获得文本字体高度
(cdr (assoc 40 (entget (car (nentsel)))))
;获得文本三维坐标
(cdr (assoc 10 (entget (car (nentsel)))))
;获得文本属性
(defun f(x)(cdr (assoc x (entget (car (nentsel))))))
;批量生成序号
(defun g(p1 p2 h con len)
    (if(> len 0)
        (progn
        (setq x1(car p1))
        (setq y1(cadr p1))
        (setq x2(car p2))
        (setq y2(cadr p2))
        (setq x3(+ x2 (- x2 x1)))
        (setq y3(+ y2 (- y2 y1)))
        (setq p3(list x3 y3 0.0))
        (setq con1(itoa (1+ (atoi con))))
        (command "text" p3 h 0 con1)
        (setq len(1- len))
        (g p2 p3 h con1 len)
        )
    )
)

;对表中的文本进行分类汇总
(defun g(lt)
    (setq e (car lt))
    (if (/= e nil)
        (progn
        (setq lt1(vl-remove e lt))
        (setq len1 (length lt))
        (setq len2 (length lt1))
        (princ (strcat e "出现的次数为:\n"))
        (princ (- len1 len2))
        (princ "\n")
        (g lt1)
        )    
    )
)
;返回文本集合表
(defun f()
    (setq s
        (ssget (list (cons 0  "text")))
    )
    (setq sl
        (sslength s)
    )
    (setq st 0)
    (setq lt(list))
    (while (< st sl)
        (setq e(ssname s st))
        (setq st(1+ st))
        (setq txt
            (cdr (assoc 1 (entget e)))
        )
        (setq lt(cons txt lt))
    )
)

;对数字文本进行求和
(defun f()
    (setq s
        (ssget '((0 . "TEXT") (1 . "~*[~`--9]*")))
    )
    (setq sl
        (sslength s)
    )
    (setq st 0)
    (setq j 0)
    (while (< st sl)
        (setq e(ssname s st))
        (setq st(1+ st))
        (setq i
            (atoi (cdr (assoc 1 (entget e))))
        )
        (setq j(+ j i))
    )
    (princ "求和结果为:")
    (eval j)
)

;以两文本为基准,移动选中的文本
;1、指定基点文本,
;2、指定第二点文本,
;3、选择要移动的文本,
;4、选择要删除的文本
(defun f()
    (setq p1
        (cdr (assoc 10 (entget (car (nentsel "指定基点文本")))))
    )
    (setq p2
        (cdr (assoc 10 (entget (car (nentsel "\n指定第二点文本")))))
    )
    (princ "\n选择要移动的文本")
    (setq s
        (ssget (list (cons 0  "text")))
    )
    (princ "选择要删除的文本")
    (setq s1
        (ssget (list (cons 0  "text")))
    )
    (if (/= s nil)
        (progn
        (command "erase" s1 "")
        (command "move" s "" p1 p2 " ")
        )
    )
)


;缩放文本
;1、指定第一参考文本,
;2、指定第二参考文本,
;3、选择要缩放的文本,
;4、指定基点
(defun f()
    (setq x
        (cdr (assoc 40 (entget (car (nentsel "指定第一参考文本")))))
    )
    (setq y
        (cdr (assoc 40 (entget (car (nentsel "\n指定第二参考文本")))))
    )
    (setq s
        (ssget (list (cons 0  "text")))
    )
    (setq p
        (getpoint "指定基点")
    )
    (setq div(/ x y))
    (command "scale" s "" p div " ")
)

;设置指定文本颜色
;1指定要查找的文本
;2指定查找范围
;3设定查找到的文本颜色
(defun f()
    (setq x 
        (cdr 
            (assoc 1 
                (entget 
                    (car (nentsel "\n请指定单个文字对象"))
                )
            )
        )
        
    )
    (princ "\n请选择要匹配的文字对象")
    (setq s
        (ssget 
            (list
                '(0 . "text")
                (cons '1 x)
            )
        )
    )
    (if (/= s nil)
        (progn
        (setq i(getint "请输入颜色编号:1 红、2 黄、3 绿、4 青、5 蓝、6 洋红、7 白/黑"))
        (command "change" s "" "p" "c" i "")
        )
    )
)




;将指定文本颜色设定为红色,x为查询字符串
;调用实例:(f "6A/3P")
(defun f(x)
    (setq x1
        (strcat "*" x "*")
    )
    (setq s
        (ssget 
            (list
                '(0 . "text")
                (cons '1 x1)
            )
        )
    )
    (if (/= s nil) 
        (command "change" s "" "p" "c" 1 "")
    )
)

;将指定文本颜色设定为红色,x为查询字符串,y为要过虑掉的字符串
;调用实例:(f "6A/3P" "D6A/3P")
(defun f(x y)
    (setq x1
        (strcat "*" x "*")
    )
    (setq y1
        (strcat "*" y "*")
    )
    (setq s
        (ssget 
            (list 
                '(0 . "text")
                '(-4 . "")
                '(-4 . "AND>")
            )
        )
    )
    (if (/= s nil) 
        (command "change" s "" "p" "c" 1 "")
    )
)

;将指定文本颜色设定为红色,x为查询字符串,y,z为要过虑掉的字符串
;调用实例:(f "6A/3P" "D6A/3P" "16A/3P")
(defun f(x y z)
    (setq x1
        (strcat "*" x "*")
    )
    (setq y1
        (strcat "*" y "*")
    )
    (setq z1
        (strcat "*" z "*")
    )
    (setq s
        (ssget 
            (list 
                '(0 . "text")
                '(-4 . "")
                    '(-4 . "")
                '(-4 . "AND>")
            )
        )
    )
    (if (/= s nil) 
        (command "change" s "" "p" "c" 1 "")
    )
)