Convert Text to Attribute

Convert Text to Attribute

dpalmerVQ54W
Enthusiast Enthusiast
4,878 Views
3 Replies
Message 1 of 4

Convert Text to Attribute

dpalmerVQ54W
Enthusiast
Enthusiast

I have a title block which is made up of two rows of single line text and I would like to convert these to being a block with attributes. Is there a command to convert the single line text to an attribute?

 

Capture.JPG

David P
AutoCAD 2021
0 Likes
4,879 Views
3 Replies
Replies (3)
Message 2 of 4

leothebuilder
Advisor
Advisor

Welcome to this forum.

No, there is no command to convert text to an attribute.

 

You will have to use the ATTDEF command and create the attribute definitions.

Message 3 of 4

Kent1Cooper
Consultant
Consultant

Try this [minimally tested]:

 

(defun C:T2A (/ tss tent tdata txt); = Text (To) Attribute
  (prompt "\nTo convert Text object(s) to Attribute definition(s),")
  (if (setq tss (ssget '((0 . "TEXT"))))
    (repeat (setq n (sslength tss)); then
      (setq
        tent (ssname tss (setq n (1- n)))
        tdata (entget tent)
        txt (cdr (assoc 1 tdata)); text content to use as both Tag and Prompt
      ); setq
      (entmake
        (append
          '((0 . "ATTDEF")); new entity type
          (vl-remove-if '(lambda (x) (member (car x) '(-1 0 330 5 100 1))) tdata)
            ; everything common between both kinds [except expendable 100 entries]
          (list '(1 . "") (cons 3 txt) (cons 2 txt) '(70 . 0) '(74 . 0))
            ; 1 entry different in ATTDEF from TEXT; others in ATTDEF but not in TEXT
        ); append
      ); entmake
      (entdel tent); eliminate original Text object
    ); repeat
  ); if
  (princ)
); defun
Kent Cooper, AIA
Message 4 of 4

Anonymous
Not applicable

There is an add-in on the Autodesk App Store for AutoCAD 2021.  It's names Text To Attribute 2021.  It also works with all the AutoCAD 2021 verticals.