;;;***************************************
;;; No.20-1 TEXT对象转换为属性对象 函数   
;;;***************************************
(defun C:ayText2Att (/ SS1 n txtEnt AA A1 A73 LST_210	LST_10)
  ;(AYCMDINIT0);保存用户系统变量.
	(vl-cmdf "_.undo" "_group")
  (setvar "blipmode" 0)
	(princ "\n选择TEXT文本对象: ")
  (setq SS1 (SSget '((0 . "TEXT"))))
  (vl-cmdf "_.UCS" "W")
  (setq n 0)
  (repeat (sslength SS1)
    (setq txtEnt (ssname SS1 n))
    (setq LST_210 (append LST_210 (list (assoc 210 (entget txtEnt)))))
    (setq LST_10 (append LST_10 (list (assoc 10 (entget txtEnt)))))
    (setq AA (member '(100 . "AcDbEntity") (entget txtEnt)))
    (setq A73 (cdr (assoc 73 AA)))
    (setq A1 (cdr (assoc 1 AA)))
    (entmake (append '((0 . "ATTDEF")) (reverse (cddr (reverse AA)))
										 '((100 . "AcDbAttributeDefinition") (70 . 8))
										 (list (cons 74 A73) (cons 3 A1) (cons 2 A1))
	     				);end_append
    );end_entmake
    (setq n (1+ n))
  );end_repeat
  (vl-cmdf "_.erase" SS1 "")
  (vl-cmdf "_.UCS" "P")
	;(AYCMDINIT1);恢复用户系统变量.
);end_defun

;;;***************************************
;;; No.20-2 属性对象转换为TEXT对象 函数   
;;;***************************************
(defun C:ayAtt2Text (/ addto dotList entData entName i newTEXT n SS1)
	;(AYCMDINIT0);保存用户系统变量.
	(princ "\n选择ATTDEF属性对象: ")
	(setq SS1 (SSget '((0 . "ATTDEF"))))	
	(setq n (sslength SS1))
	(setq i 0)
	(while (< i n)
		(setq entName (ssname SS1 i))
		(setq entData (entget entName))
		(setq newTEXT '((0 . "TEXT")))
		(setq newTEXT (append newTEXT (list (cons 1 (cdr (assoc 2 entData)))))); 2=ATTDEF中的标记内容.
		(setq dotList (list 7 8 10 11 39 40 41 50 51 62 71 72 73));建立一个有关"TEXT群码"的表.
		(foreach grp dotList
			(setq addto (assoc grp entData))
		  (if	(/= addto nil) (setq newTEXT (append newTEXT (list (assoc grp entData)))))
		);end_foreach 从"属性定义"中提取与"TEXT群码"值相对应的"点对列表"添加到新文字的数据列表中.
		(entdel entName)
		(entmake newTEXT)
		(setq i (1+ i))
	);end_while
	;(AYCMDINIT1);恢复用户系统变量.
);end_defun
