Jump to content

Can I change Mtext or Dtext into a Defined Attribute?


magwea

Recommended Posts

Is there a simple way of doing this out there. Normally its easy enough to just retype, but sometimes, (eg with regards to the justification, height, style, location) its not so easy. Anyone help me out.

Link to comment
Share on other sites

Try this LISP routine. Hope it helps.

 

;Tip1791:  TXT2ATTDEF.LSP  TEXT TO ATTRIBUTES              (c)2002, Sanjay Kulkarni 

(defun C:TXT2ATTDEF (PCMDECHO TXT1 IFTXT TXT1VAL TXT1IP TXT1HT TXT1ROT APRMPT PAFLAGS) 
 (setq PCMDECHO (getvar "CMDECHO")) 
 (setvar "CMDECHO" 0) 
 (setq TXT1 (entget (car (entsel "\nSelect Text : ")))) 
 (setq IFTXT (cdr (assoc 0 TXT1))) 
 (while (/= IFTXT "TEXT") 
   (setq 
     TXT1 
      (entget 
        (car 
          (entsel 
            (strcat 
              "\nSelection Error !! You selected " 
              IFTXT 
              "! \nPlease Select Text : " 
            ) ;_ end of strcat 
          ) ;_ end of entsel 
        ) ;_ end of car 
      ) ;_ end of entget 
   ) ;_ end of setq 
   (setq IFTXT (cdr (assoc 0 TXT1))) 
 ) ;_ end of while 
 (setq TXT1VAL (cdr (assoc 1 TXT1))) 
 (setq TXT1IP (cdr (assoc 10 TXT1))) 
 (setq TXT1HT (cdr (assoc 40 TXT1))) 
 (setq TXT1ROT (cdr (assoc 50 TXT1))) 
 (setq APRMPT (getstring T "\nAttribute prompt : ")) 
 (entdel (cdar TXT1)) 
 (setq PAFLAGS (getvar "AFLAGS")) 
 (setvar "AFLAGS" 0) 
 (command "attdef" 
   "" 
   TXT1VAL 
   APRMPT 
   TXT1VAL 
   TXT1IP 
   TXT1HT 
   (/ (* TXT1ROT 180) (/ 22.0 7.0)) 
 ) ;_ end of command 
 (setvar "AFLAGS" PAFLAGS) 
 (setvar "CMDECHO" PCMDECHO) 
 (princ) 
) ;defun txt2attdef

Source: http://cadtips.cadalyst.com/attributed-blocks/text-attributes

Link to comment
Share on other sites

Thanks uddfl, sorry for not replying sooner, i'll give the lisp a go -never needed to use them before-, although, i'm kind of surprised that there isn't a tool build into Ac to do this already.

Link to comment
Share on other sites

  • 1 month later...

This seems handy, but I get an error "TXT2ATTDEF ; error: too few arguments" when I give it a run. I take it neither one of you did?

 

I've been trying it on a Mtext with multiple fields, so maybe the fields are messing it up...:oops:

Link to comment
Share on other sites

I get an error "TXT2ATTDEF ; error: too few arguments" when I give it a run.

 

I've been trying it on a Mtext with multiple fields

It only works with one-line TEXT, not MTEXT.
Link to comment
Share on other sites

  • 2 months later...

Help I am fianaly sorting out my block libary I have fuse holder blocks that have attributes associated with them docked on a tool pallett. My question is: can attributes be defined as Mtext so that justification can be applied ? the various names of the fuse holder varies in length and often the justification is way off when I fill in the attributes

thanks all

Link to comment
Share on other sites

Help I am fianaly sorting out my block libary I have fuse holder blocks that have attributes associated with them docked on a tool pallett. My question is: can attributes be defined as Mtext so that justification can be applied ? the various names of the fuse holder varies in length and often the justification is way off when I fill in the attributes

thanks all

 

Attributes can be assigned any of the text justifications. And in 2009 and 2010 you can specify multiple lines.

Link to comment
Share on other sites

thanks rkent I spent some time and arrived at the same conclusion,

since I posted my help.

My company has no plans to upgrade to 2009/2010

so I'll have to keep shoving sqare pegs into round holes

but thank you again

Link to comment
Share on other sites

NAILER20

 

Try BATTMAN you can select a block and globally change the properties of the attributes. Don't forget to sync the block.

Link to comment
Share on other sites

  • 6 years later...

This is the error I get, any clues? AutoCAD 2013, thx!

Command: TXT2ATTD

Select A TEXT to Convert to ATTDEF:

; error: bad argument type: lselsetp nil

 

 

Try this LISP routine. Hope it helps.

 

;Tip1791:  TXT2ATTDEF.LSP  TEXT TO ATTRIBUTES              (c)2002, Sanjay Kulkarni 

(defun C:TXT2ATTDEF (PCMDECHO TXT1 IFTXT TXT1VAL TXT1IP TXT1HT TXT1ROT APRMPT PAFLAGS) 
 (setq PCMDECHO (getvar "CMDECHO")) 
 (setvar "CMDECHO" 0) 
 (setq TXT1 (entget (car (entsel "\nSelect Text : ")))) 
 (setq IFTXT (cdr (assoc 0 TXT1))) 
 (while (/= IFTXT "TEXT") 
   (setq 
     TXT1 
      (entget 
        (car 
          (entsel 
            (strcat 
              "\nSelection Error !! You selected " 
              IFTXT 
              "! \nPlease Select Text : " 
            ) ;_ end of strcat 
          ) ;_ end of entsel 
        ) ;_ end of car 
      ) ;_ end of entget 
   ) ;_ end of setq 
   (setq IFTXT (cdr (assoc 0 TXT1))) 
 ) ;_ end of while 
 (setq TXT1VAL (cdr (assoc 1 TXT1))) 
 (setq TXT1IP (cdr (assoc 10 TXT1))) 
 (setq TXT1HT (cdr (assoc 40 TXT1))) 
 (setq TXT1ROT (cdr (assoc 50 TXT1))) 
 (setq APRMPT (getstring T "\nAttribute prompt : ")) 
 (entdel (cdar TXT1)) 
 (setq PAFLAGS (getvar "AFLAGS")) 
 (setvar "AFLAGS" 0) 
 (command "attdef" 
   "" 
   TXT1VAL 
   APRMPT 
   TXT1VAL 
   TXT1IP 
   TXT1HT 
   (/ (* TXT1ROT 180) (/ 22.0 7.0)) 
 ) ;_ end of command 
 (setvar "AFLAGS" PAFLAGS) 
 (setvar "CMDECHO" PCMDECHO) 
 (princ) 
) ;defun txt2attdef

Source: http://cadtips.cadalyst.com/attributed-blocks/text-attributes

Link to comment
Share on other sites

Two solutions to your problem were included in the thread you first posted to (re: your question about updates to AutoCAD 2013). See post #7 by David Bethel and post #8 by Lee Mac. Both forum members are known for the quality of their lisp routines.

 

http://www.cadtutor.net/forum/showthread.php?28205-Text-2-Attribute

 

Did you ever figure out whether or not you had the last service pack for 2013 installed?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...