Jump to content

Convert text to mtext in lisp?


muck

Recommended Posts

Subject Convert text to mtext in lisp?

What lisp command to convert strings to mtext?

 

I am looking for (or maybe making) a lisp routine that would change text

to mtext by allowing the user to select a group of strings in a drawing.

The routine would change the first text string to mtext then

allow the user edit that string. Then the routine would go down to the second string to make a mtext conversion then let the user edit that string. Then the rountine would to the the third string and so on. Hopefully the routine would move form left to right then down. Simular movement as reading a book. Has anyone done this??

 

First things first, Does anyone know a lisp command to convert text to mtext?

 

 

thank you,

Link to comment
Share on other sites

what version of CAD are you running? If it's the full version, then you probably already have this feature via Express Tools. type TXT2MTXT at the command line and follow the prompt.

 

:)

Link to comment
Share on other sites

AutoCAD Version 2007. I noticed when a person uses a pull down (ie txt2mtxt) menu to select a group of texts strings the command will put all the strings into one mtext box. Usually the top mtext box. I really don't want that. If I select 10 text strings to convert to mtext I would like to get 10 mtext boxes in there orginal postions by window picking a group of text strings. Hopefully the mtext would be in the same positions as the previous

text strings.

thank you,

Link to comment
Share on other sites

That can be done in lisp, but most people wanted to group severeal dtexts into one mtext.

 

What bout this: run the command txt2mtxt, select one text, then press enter to repeat and select the next and so on?

Link to comment
Share on other sites

If I select 10 text strings to convert to mtext I would like to get 10 mtext boxes in there orginal postions by window picking a group of text strings.

Try this...

;changes text to individual mtext by Carl B.

(princ "\nType T2M to start")
(defun c:t2m ()
 (setq Tset (ssget '((0 . "*TEXT"))))   ;filter text in selection set
                   
 (setq    Setlen (sslength Tset)       ;setq number of entties in selection set, setq count(er) to 0
   Count  0
 )
                   
 (repeat SetLen                             ;repeat setq times
                   
   (setq Ename (ssname Tset Count))   ;setq ename to be the "0..." entity in selection set Tset
                   
   (command "_txt2mtxt" Ename "")
   (setq Count (+ 1 Count))                  ; add 1 to Count(er)
                   
 )                ; Repeat    
 (princ)
)

Link to comment
Share on other sites

I will try the above code and see what it does.

Here is one thing I have found.

 

(command "txt2mtxt" "")

;Opens Mtext Conversion options dialog. If I turn off wordwrap

;feature in the dialog box my window conversions will keep the text in

;place but I don't know how to turn off that the wordwrap

;feature using lisp. Interesting Information.

Link to comment
Share on other sites

I am looking for (or maybe making) a lisp routine that would change text to mtext by allowing the user to select a group of strings in a drawing.

 

ToolPac includes a routine to convert multiple TEXT entities to MTEXT, without combining them.

Link to comment
Share on other sites

That can be done in lisp, but most people wanted to group severeal dtexts into one mtext.

 

What bout this: run the command txt2mtxt, select one text, then press enter to repeat and select the next and so on?

 

 

I read this and I would like to know if there are some lsp routine to change the high of mtext at same time, por example, if I have 10 mtext box, but with differents highs, select all of them and give them the same high, and keeping the same start point.

 

Thank for the help!!

 

Oskr

Link to comment
Share on other sites

Yes, it's possible but the problem with Mtext is that you can have all kinds of format overrides inside the text.

If the Mtexts are all with default formatting, you can use the Properties window to change the hight.

Link to comment
Share on other sites

  • 1 year later...

Thanks Lee Mac......i am currently working with a drawing which has lots of layers overlaying each other and if i was to explode the text i will have to isolate the text and then explode.....its only when i turn the layers back on that i have the issue of re-setting the layers back to how they should be.....as in which layer is to be set behind the other.....it adds to my other problems i have...

 

Any addvice or assistance on the two issues will be kindy acknowledged.

 

Thanks

 

Just explode it :)
Link to comment
Share on other sites

Ok, firstly, for ordering layers - perhaps this?

 

(defun c:orderlay  (/ laylist ss)

 (setq laylist '("LAYER1"  ;  <---<< List Layers Here.
                 "LAYER2"
                 "LAYER3"
         ))
 
 (foreach lay laylist
   (if    (and (tblsearch "LAYER" lay)
        (setq ss (ssget "X" (list (cons 8 lay)))))
     (command "_draworder" ss "" "_F")))
 (princ))

 

Will send each layer in the list to the front in turn. - hence ordering the layers

Link to comment
Share on other sites

As for exploding each item of multi-line text, try this:

 

(defun c:texp (/ ss)
 (if (setq ss (ssget "X" (list (cons 0 "MTEXT")
   (if (getvar "CTAB")(cons 410 (getvar "CTAB"))
      (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (foreach ent (mapcar 'cadr (ssnamex ss))
   (command "_explode" ent)))
   (princ "\n<!> No Text Found <!>"))
 (princ))

Link to comment
Share on other sites

Hi Lee Mac

 

Thank you so much for your kind help....the lisp codes work great and saves me a lot of time.......

 

Cheers

 

 

Excellent - I'm happy they perform as required :)

 

Anything else, just ask :)

Link to comment
Share on other sites

  • 1 year later...
what version of CAD are you running? If it's the full version, then you probably already have this feature via Express Tools. type TXT2MTXT at the command line and follow the prompt.

 

:)

 

works like a charm thanks

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...