Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

text to mtext

9 REPLIES 9
Reply
Message 1 of 10
rphillips
1621 Views, 9 Replies

text to mtext

I am looking for someting to convert text to mtext.
I am aware to the TXT2MTXT but this does not work like i need it to.
The command above will allow a selection of mutiple text but then it converts all that text to one piece of mtext.
I am looking for something that will allow me to select mutiple text objects and it convert them to mtext without combining them into one piece of text.

reason for this
We have some contour lables that are all justified left and once selected to change the size
of the text it does not line up with the line any longer
So if i can get them to be mtext i can change the justification all at once then asign a new text height and then the text will line up right.

Thanks
9 REPLIES 9
Message 2 of 10
lpseifert
in reply to: rphillips

{code}
;changes text to individual mtext by Carl B.
(princ "\nType T2M to start")
(defun c:t2m ()
(setq Tset (ssget '((0 . "*TEXT"))))
(setq Setlen (sslength Tset)
Count 0
)
(repeat SetLen
(setq Ename (ssname Tset Count))
(command "_txt2mtxt" Ename "")
(setq Count (+ 1 Count))
)
(princ)
)
{code}
BTW... if you use Express tools' Tjust command you can change the text's justification, but the position will stay the same
~~~Civil 3D 2008~~~
Message 3 of 10
rphillips
in reply to: rphillips

Thanks that works great
Message 4 of 10
jimdi4
in reply to: rphillips

That appears to be looking for the TXT2MTXT command...>AC 2009 doesn't use this command anymore...At least when I tried running it

I got :


T2M
Select objects: Specify opposite corner: 3 found

Select objects:
_txt2mtxt Unknown command "TXT2MTXT". Press F1 for help.

Command:

T2M Unknown command "T2M". Press F1 for help.

Command: T2M Unknown command "T2M". Press F1 for help.

Command: _txt2mtxt Unknown command "TXT2MTXT". Press F1 for help.

Command:

Command: ; error: Function cancelled

Command: *Cancel*

Command:
Command:
Command: _erase
Select objects: Specify opposite corner: 3 found

Select objects:
Message 5 of 10
Anonymous
in reply to: rphillips

Try this:

;;; ATXT2MTXT
;;; Written by David Forbus 25oct2008
;;; ATXT2MTXT creates multiple Mtext objecs from multiple text objects
;;;

(defun c:ATXT2MTXT (/ OBJECT_SET COUNTER OBJECT_CURRENT COUNTER_2
OP-7 OP-73 OP-1 OP-11 OP-10 OP-210 OP-40 OP-50 OP-71 OP-72 OP-8)
(setvar "cmdecho" 0)
(princ "Select text ")
(setq OBJECT_SET (ssget (list (cons 0 "TEXT"))))
(setq COUNTER (1- (sslength OBJECT_SET)))
(while (> COUNTER -1.0)
(setq OBJECT_CURRENT (entget (ssname OBJECT_SET counter)))
(setq COUNTER_2 (1- (length OBJECT_CURRENT)))
(while (> COUNTER_2 -1.0)
(setq OBJECT_PARAMETER (nth COUNTER_2 OBJECT_CURRENT))
(if (= (car OBJECT_PARAMETER) 73)(setq OP-73 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 1)(setq OP-1 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 11)(setq OP-11 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 10)(setq OP-10 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 210)(setq OP-210 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 40)(setq OP-40 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 50)(setq OP-50 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 7)(setq OP-7 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 71)(setq OP-71 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 72)(setq OP-72 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 8)(setq OP-8 (cdr OBJECT_PARAMETER)))
(setq COUNTER_2 (1- COUNTER_2)))
(entmake (list
(cons 0 "MTEXT")
(cons 100 "AcDbEntity")
(cons 100 "AcDbMText")
(cons 42 1)
(cons 43 0)
(cons 44 1)
(cons 7 OP-7)
(cons 73 OP-73)
(cons 1 OP-1)
(cons 11 OP-11)
(cons 10 OP-10)
(cons 210 OP-210)
(cons 40 OP-40)
(cons 50 OP-50)
(cons 71 OP-71)
(cons 72 0)
(cons 8 OP-8))
)
(setq COUNTER (1- COUNTER)))
(command "erase" "p" "")
)

(princ "Type \"ATXT2MTXT\" to convert multiple text objects to multiple Mtext objects.")
Message 6 of 10
jimdi4
in reply to: rphillips

I should have started another thread with this request, actually I am looking to get the text grouped not ungrouped like this thread started out as...
Message 7 of 10
Anonymous
in reply to: rphillips

This is a quick and dirty variation of the previous one. It does basically the same as TXT2MTXT.

;;; ATEXT2MTEXT
;;; Written by David Forbus 6APR2009
;;; TEXT2MTEXT creates a single Mtext object from multiple text objects
;;;

(defun c:TEXT2MTEXT (/ OBJECT_SET COUNTER OBJECT_CURRENT COUNTER_2
OP-7 OP-73 OP-1 OP-11 OP-10 OP-210 OP-40 OP-50 OP-71 OP-72 OP-8)
(setvar "cmdecho" 0)
(princ "Select text ")
(setq OBJECT_SET (ssget (list (cons 0 "TEXT"))))
(setq TXT-STRING "")
(setq COUNTER (1- (sslength OBJECT_SET)))
(while (> COUNTER -1.0)
(setq OBJECT_CURRENT (entget (ssname OBJECT_SET counter)))
(setq COUNTER_2 (1- (length OBJECT_CURRENT)))
(while (> COUNTER_2 -1.0)
(setq OBJECT_PARAMETER (nth COUNTER_2 OBJECT_CURRENT))
(if (= (car OBJECT_PARAMETER) 73)(setq OP-73 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 1)(setq OP-1 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 11)(setq OP-11 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 10)(setq OP-10 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 210)(setq OP-210 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 40)(setq OP-40 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 50)(setq OP-50 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 7)(setq OP-7 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 71)(setq OP-71 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 72)(setq OP-72 (cdr OBJECT_PARAMETER)))
(if (= (car OBJECT_PARAMETER) 8)(setq OP-8 (cdr OBJECT_PARAMETER)))
(setq COUNTER_2 (1- COUNTER_2)))
(setq TXT-STRING (strcat TXT-STRING OP-1 "\\P" ))
(setq COUNTER (1- COUNTER)))
(entmake (list
(cons 0 "MTEXT")
(cons 100 "AcDbEntity")
(cons 100 "AcDbMText")
(cons 42 1)
(cons 43 0)
(cons 44 1)
(cons 7 OP-7)
(cons 73 OP-73)
(cons 1 TXT-STRING)
(cons 11 OP-11)
(cons 10 OP-10)
(cons 210 OP-210)
(cons 40 OP-40)
(cons 50 OP-50)
(cons 71 OP-71)
(cons 72 0)
(cons 8 OP-8))
)
(command "erase" "p" "")
)

(princ "Type \"TEXT2MTEXT\" to convert multiple text objects to multiple Mtext objects.")
Message 8 of 10
jimdi4
in reply to: rphillips

That command didn't work text still 3 sepearate pieces of text aalso note error below



Command: _appload ATXT2MTXT.LSP successfully loaded.


Command:
Command:
Command: ATXT2MTXT
Select text
Select objects: Specify opposite corner: 3 found

Select objects:
nil

Command: *Cancel*

Command: ATXT2MTXT
Select text
Select objects: Specify opposite corner: 0 found

Select objects:
; error: bad argument type: lselsetp nil

Command:
Message 9 of 10
Anonymous
in reply to: rphillips

Check your spelling. You loaded the old one. The names are slightly different. Keep in mind if you have already converted the individual text elements to MTEXT elements. You will have to explode them to start over.
Message 10 of 10
jimdi4
in reply to: rphillips

Thank you, Thank you, Thank you, Thank you,

Finally I found soemone who knows what their doing!!!

You rock!!!

JL

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost