+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 27
  1. #1
    Full Member rustym's Avatar
    Computer Details
    rustym's Computer Details
    Operating System:
    Windows, Ubuntu, Presto Linux
    Using
    AutoCAD 2010
    Join Date
    Mar 2009
    Location
    South Africa
    Posts
    31

    Question Convert text to attribute

    Registered forum members do not see this ad.

    I am creating blocks witch run from tag_1 to tag_6 and then from tag_7 to tag_12 for the next dwg and so on and takes time renaming all the tags for each block. So I like the create my tag_1 to tag_40 in excel, copy it to Autocad, explode in to single line txt and then convert the text to be my attribute tag and then it be just a matter of making the blocks containing of 6 tags each.

    I've found a txt2att.lsp somewhere but it converts the txt to the attribute value and set the tag name to 'label'. I need it to convert the singe line text to attribute tag.

    Thanx for any advice or lisp program for that matter.

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,875

    Default

    Quick and dirty:

    Code:
    (defun c:txt2tag (/ oldcmd ss)
      (setq oldcmd (getvar "CMDECHO")) (setvar "CMDECHO" 0)
      (if (setq ss (ssget (list (cons 0 "TEXT")
        (if (getvar "CTAB")(cons 410 (getvar "CTAB"))
           (cons 67 (- 1 (getvar "TILEMODE")))))))
        (progn
           (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
         (command "-attdef" "" (cdr (assoc 1 (entget e))) "" ""
              (cdr (assoc 10 (entget e))) "")
         (entdel e)))
        (princ "\n<!> No Text Selected <!>"))
      (setvar "CMDECHO" oldcmd)
      (princ))
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Full Member rustym's Avatar
    Computer Details
    rustym's Computer Details
    Operating System:
    Windows, Ubuntu, Presto Linux
    Using
    AutoCAD 2010
    Join Date
    Mar 2009
    Location
    South Africa
    Posts
    31

    Default

    O you are a star Lee Mac. Thank you very much!!

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,875

    Default

    No probs Happy to help
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Full Member rustym's Avatar
    Computer Details
    rustym's Computer Details
    Operating System:
    Windows, Ubuntu, Presto Linux
    Using
    AutoCAD 2010
    Join Date
    Mar 2009
    Location
    South Africa
    Posts
    31

    Default

    Is it possible to make it select more than one text at a time. I seems like it suppose to do that but it gives an error and just converting one of them.

    thanx again

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,875

    Default

    It seems to work for me when I try it on multiple text objects - what error does it give?
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Full Member rustym's Avatar
    Computer Details
    rustym's Computer Details
    Operating System:
    Windows, Ubuntu, Presto Linux
    Using
    AutoCAD 2010
    Join Date
    Mar 2009
    Location
    South Africa
    Posts
    31

    Default

    Here is the text after selecting 2 objects and it then continues converting only the 1ste selected one after the rotation is entered:

    Command: TXT2TAG
    Select objects: 1 found

    Select objects: 1 found, 2 total

    Select objects:
    Requires valid numeric angle or second point.
    ; error: Function cancelled

    Specify rotation angle of text <0>:

  8. #8
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,069

    Default

    You might want to look here:

    http://www.cadtutor.net/forum/showth...light=txt2attd

    -David
    R12 (Dos) - A2K

  9. #9
    Full Member rustym's Avatar
    Computer Details
    rustym's Computer Details
    Operating System:
    Windows, Ubuntu, Presto Linux
    Using
    AutoCAD 2010
    Join Date
    Mar 2009
    Location
    South Africa
    Posts
    31

    Default

    Thanks, did not even find that post through the search... anyway that works even better as it adds the Prompt as well and not asking for the rotation witch is unnecessary in my case, but unfortunately not converting multiple selected text.


    Quote Originally Posted by David Bethel View Post
    You might want to look here:

    http://www.cadtutor.net/forum/showth...light=txt2attd

    -David

  10. #10
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,069

    Default

    Registered forum members do not see this ad.

    Try this for multiple selections
    Code:
    (defun c:txt2atta (/ ss i en ed)
      (while (not ss)
             (princ "\nSelect TEXT to Convert to ATTDEF:   ")
             (setq ss (ssget (list (cons 0 "TEXT")
                                   (if (getvar "CTAB")
                                       (cons 410 (getvar "CTAB"))
                                       (cons 67 (- 1 (getvar "TILEMODE"))))))))
    
      (setq i (sslength ss))
      (while (not (minusp (setq i (1- i))))
             (setq en (ssname ss i)
                   ed (entget en))
             (if (wcmatch (cdr (assoc 1 ed)) "* *")
                 (alert "\nString Contains Spaces - Try Again...")
                 (progn
                   (entmake (list (cons 0 "ATTDEF")
                                  (assoc 8 ed)
                                  (assoc 10 ed)
                                  (assoc 11 ed)
                                  (assoc 7 ed)
                                  (assoc 40 ed)
                                  (assoc 41 ed)
                                  (assoc 50 ed)
                                  (assoc 51 ed)
                                  (cons 70 0)
                                  (assoc 71 ed)
                                  (assoc 72 ed)
                                  (cons 74 (cdr (assoc 73 ed)))
                                  (assoc 210 ed)
                                  (cons 1 "")
                                  (cons 2 (cdr (assoc 1 ed)))
                                  (cons 3 (cdr (assoc 1 ed)))
                                  (if (assoc 6 ed) (assoc 6 ed)'(6 . "BYLAYER"))
                                  (if (assoc 39 ed) (assoc 39 ed)'(39 . 0))
                                  (if (assoc 62 ed) (assoc 62 ed)'(62 . 256))))
                   (entdel en))))
      (redraw)
      (prin1))
    -David
    R12 (Dos) - A2K

Similar Threads

  1. Convert text to a block
    By ORgrown in forum AutoCAD General
    Replies: 4
    Last Post: 22nd Jul 2013, 09:29 pm
  2. Text Attribute
    By frankie78 in forum AutoCAD General
    Replies: 5
    Last Post: 6th Feb 2009, 09:37 am
  3. Text 2 Attribute
    By Srinivas.Vinjamuri in forum AutoCAD Beginners' Area
    Replies: 10
    Last Post: 23rd Jan 2009, 02:42 pm
  4. Convert Text to Mtext
    By CAD-e-Corner in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 5th Sep 2006, 09:14 pm
  5. Convert text entitys to x,y,z
    By Paul Mc in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 4th May 2006, 10:30 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts