We're looking for a routine to convert multiple Dtext text objects to Mtext object. The problem we are having is that when we run txt2mtxt over our dtext in AutoCAD 2011 the dtext is converted to mtext but all in one mtext object.
We are actually trying to text mask multiple dtexts but they seem to be deleted when the mask is created. so something that can achieve that would also be a solution.
You can select multiple objects and process them one at a time
Try something like this
(defun c:test (/ text_objects cnt) (setq text_objects (ssget '((0 . "TEXT"))) cnt -1) (while (setq e (ssname text_objects (setq cnt (1+ cnt)))) (setq ent_to (entget e) typ (cdr (assoc 0 ent_to)) pt (cdr (assoc 10 ent_to)) str (cdr (assoc 1 ent_to)) ht (cdr (assoc 40 ent_to)) rt (cdr (assoc 50 ent_to)) jt (cdr (assoc 71 ent_to)) sst (cdr (assoc 7 ent_to)) ) (entdel e) (PBE:MText pt str ht rt sst) ) ) (defun PBE:MText (pt str ht rt sst / Txt_created) (setq Txt_created (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 pt) (cons 1 str) (cons 40 ht) (cons 50 rt) (cons 71 jt) (cons 7 sst) '(90 . 1) '(63 . 1) '(441 . 3935927);<---- this is index color red ) ) ) (if Txt_created (progn (setq nct (entlast) ent_mod (entget nct) ) (entmod (subst (cons 71 7) (assoc 71 ent_mod) ent_mod)) ) )(princ) )
it will convert the text to mtext and mask it RED (color index).. change it to whatever color you want
I suggest you add prompt for color if you have to :-)
Now if you need true color you have to add DXF 421
In case you're wondering what the entmod is for.. notice when you use txt2mtxt commnad the position of the text is shifted. that line will move it to where it was before (at leat in theory)
hope this helps
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register