Explode Attributes to Text

Discussion in 'AutoCAD' started by Greg McLandsborough, Feb 23, 2005.

  1. Does anyone know where I can get a routine to Explode Attribute to Text, I
    know there is one in Express, but I can't get express to work in 2005, and
    would prefer to have the code.

    Any help Appreciated.

    Greg
     
    Greg McLandsborough, Feb 23, 2005
    #1
  2. Greg McLandsborough

    Adesu Guest

    Hi Greg,

     
    Adesu, Feb 23, 2005
    #2
  3. Wrote one myself last night, Does anyone want to have a look at the
    selection set handling at the end of the code to erase the Original attdefs
    and see if they can suggest make it a little more efficient


    (defun C:ExAtt->TXT (/ block objblock Attribute-List attribute Attdxf cnt
    pre-set post-set)
    (while (not block)
    (setq block (ssget ":s" '((0 . "INSERT"))))
    )
    (setq block (ssname block 0)
    objblock (vlax-ename->vla-object block)
    Attribute-List (vlax-safearray->list (vlax-variant-value (vla-getattributes
    objblock)))
    )
    (foreach attribute Attribute-list
    (setq Attdxf (entget (vlax-vla-object->ename Attribute))
    Attdxf (vl-remove (assoc 2 Attdxf) Attdxf)
    Attdxf (vl-remove (assoc 70 Attdxf) Attdxf)
    Attdxf (vl-remove (assoc 74 Attdxf) Attdxf)
    Attdxf (subst '(100 . "AcDbText") '(100 . "AcDbAttribute") Attdxf)
    Attdxf (subst '(0 . "TEXT") '(0 . "ATTRIB") Attdxf)
    )
    (entmake Attdxf)
    )
    (setq pre-set (ssget "x"))
    (vl-cmdf "_explode" block "")
    (setq post-set (ssget "x"))
    (repeat (setq cnt (sslength pre-set))
    (setq cnt (1- cnt))
    (if (ssmemb (ssname pre-set cnt) post-set)
    (ssdel (ssname pre-set cnt) post-set))
    )
    (repeat (setq cnt (sslength post-set))
    (setq cnt (1- cnt))
    (if (= (dxf 0 (entget (ssname post-set cnt))) "ATTDEF")
    (entdel (ssname post-set cnt)))
    )
    (gc)
    )

    (defun dxf (n ed) (cdr (assoc n ed)))

    Thanks for any help.
     
    Greg McLandsborough, Feb 23, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.