- ;;; 批量文本转属性定义 txtat Define the top-level function for the command "txtatt"
- (defun c:txtatt (/ ss ent)
- (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT"))))
- (progn
- (setq i 0)
- (repeat (sslength ss)
- (setq ent (ssname ss i))
- (txt2att ent)
- (setq i (1+ i))
- )
- )
- (if (setq ent (entsel "\nSelect text entity: "))
- (txt2att (car ent))
- (prompt "No entity was selected.")
- )
- )
- (princ)
- )
- ;;; Define the core function that converts a text entity to an attribute definition
- (defun txt2att (ent / entdxf newdxf malst tem)
- (setq entdxf (entget ent)
- newdxf '((0 . "ATTDEF"))
- newdxf (append
- newdxf
- (list
- (cons 1 (cdr (assoc 1 entdxf)))
- (cons 2 (cdr (assoc 1 entdxf)))
- (cons 3 (cdr (assoc 1 entdxf)))
- (cons 70 0)
- )
- )
- malst (list 7 8 10 11 39 40 41 50 51 62 71 72 73)
- )
- (foreach mai malst
- (setq tem (assoc mai entdxf))
- (if (/= tem nil)
- (setq newdxf (append newdxf (list tem)))
- )
- )
- (entdel ent)
- (entmake newdxf)
- )
|