;文字变块属性[mini_text2att]
(defun c:mini_text2att ( / old_cmd blk txt yn )


(defun vlobj_attach_attrib ( blk atx erase / att bbb nxx tmp rtn)
  (setq bbb blk
        blk (entget bbb)
  )
  (or (assoc 66 blk)
      (setq blk (append blk (list (cons 66 1))))
  )
  (setq nxx (list blk))
  (and (entnext bbb)
       (= (mai_dxf 0 (entnext bbb)) "ATTRIB")
       (while
          (/= (mai_dxf 0 (setq bbb (entnext bbb))) "SEQEND")
          (setq nxx (cons (entget bbb) nxx))
       )
  )
  (if (setq atx (mai_ssget_2_list atx))
      (progn
          (foreach att atx
                (and (setq att (entget att) tmp (mai_dxf 1 att))
                     (setq tmp (list
                                 (cons 0 "ATTRIB")
                                 (cons 100 "AcDbEntity")
                                 (cons 100 "AcDbText")
                                 (cons 100 "AcDbAttribute")
                                 (cons 1 tmp)
                                 (cons 2 (substr tmp 1 10))
                                 (cons 6 "ByBlock")
                                 (cons 7 "STANDARD")
                                 (cons 8 "0")
                                 (list 10 0.0 0.0 0.0)
                                 (list 11 0.0 0.0 0.0)
                                 (cons 40 1.0)
                                 (cons 41 1.0)
                                 (cons 50 0.0)
                                 (cons 51 0.0)
                                 (cons 62 256)
                                 (cons 70 0)
                                 (cons 72 0)
                                 (cons 73 0)
                               )
                     )
                    (progn
                        (foreach bbb '(7 8 10 11 40 41 50 51 72 73)
                           (setq tmp (subst (assoc bbb att) (assoc bbb tmp) tmp))
                        )
                        (setq nxx (cons tmp nxx))
                    )
                )
          )
          (setq nxx (cons (list (cons 0 "SEQEND") (cons 100 "AcDbEntity") (assoc 8 blk)) nxx))
          (mapcar 'entmake (reverse nxx))
          (setq rtn (entlast))
          (and erase
               (entdel (mai_dxf -1 blk))
               (mai_entdel atx nil)
          )
      )
  )
  rtn
)


  (mai_start nil)
  (setq blk (car (mai_Entsel nil "选择需要增加属性的块:<回车退出>" "没有找到块." '((0 . "insert")) nil)))
  (or blk (exit))
  (redraw blk 3)
  (setq txt (mai_select_first '((0 . "text")) "选择需要转为块属性的文字:<退出>" "没有找到文字."))
  (initget "Yen No")
  (or (setq yn (getkword "\n是否删除原有文字？[Yes/No] <Yes>:"))
      (setq yn "Yes")
  )
  (vlobj_attach_attrib blk txt (equal yn "Yes"))
  (mai_end)
)

