Author Topic: txt2mtxt  (Read 17413 times)

0 Members and 1 Guest are viewing this topic.

PHX cadie

  • Water Moccasin
  • Posts: 1902
txt2mtxt
« on: October 20, 2010, 03:30:17 PM »
Because of client standards, they do not allow single text, only mtext. The sub gives us dwgs with all single line text and I have to fix it. I've been using Express tools to convert, but I need to pick each one by one, not group everything into one paragraph.
Van Halen has  great rhythm to hitting the space bar, I can't help but wonder if there is an easier way to convert txt to mtxt?

Thx's
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: txt2mtxt
« Reply #1 on: October 20, 2010, 03:34:59 PM »
Quickie...
Code: [Select]
(defun c:Test (/ i ss e)
  (if (setq i  -1
            ss (ssget "_:L" '((0 . "TEXT")))
      )
    (while (setq e (ssname ss (setq i (1+ i)))) (command "_.txt2mtxt" e ""))
  )
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #2 on: October 20, 2010, 03:44:05 PM »
Here's my "homegrown" version:  :-)

Code: [Select]
;;; AUTHOR
;;; Copyright© 2010 Ron Perez (ronperez@gmail.com)
;;;
(defun c:t2mt (/  d     doc elst   hgt      lspc n
      nxt  obj     objtxt out   pt      ss txt
      w  x     rjp-removextraspaces  rjp-ent2obj rjp-getbbwdth
      rjp-getbbtlc     rjp-dxf
     )
  (defun rjp-removextraspaces (txt)
    (while (vl-string-search "  " txt)
      (setq txt (vl-string-subst " " "  " txt))
    )
    txt
  )
  (defun rjp-ent2obj (ent)
    (if (= (type ent) 'ename)
      (vlax-ename->vla-object ent)
      ent
    )
  )
  (defun rjp-dxf (code ent)
    (if (and ent (= (type ent) 'ename))
      (cdr (assoc code (entget ent)))
    )
  )
  (defun rjp-getbbwdth (ent / out ll ur)
    (vla-getboundingbox (rjp-ent2obj ent) 'll 'ur)
    (setq out (mapcar 'car (mapcar 'vlax-safearray->list (list ll ur))))
    (abs (- (car out) (cadr out)))
  )
  (defun rjp-getbbtlc (ent / out ll ur)
    (vla-getboundingbox (rjp-ent2obj ent) 'll 'ur)
    (setq out (mapcar 'vlax-safearray->list (list ll ur)))
    (list (caar out) (cadr (last out)) 0.0)
  )
  (if (and (setq ss (ssget ":L" (list '(0 . "text"))))
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      )
    (progn (setq elst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
;;Get widest piece of text to set mtext width
w (* 1.0125 (car (vl-sort (mapcar 'rjp-getbbwdth elst) '>)))
;;Sort text top to bottom
txt (vl-sort
 (mapcar
   '(lambda (x)
      (list
(cadr (rjp-dxf 10 x))
(strcat (rjp-removextraspaces (rjp-dxf 1 x)) " ")
x
      )
    )
   elst
 )
 (function (lambda (y1 y2) (< (car y2) (car y1))))
)
hgt (rjp-dxf 40 (last (car txt)))
pt (rjp-getbbtlc (last (car txt)))
;;Grab top text to pull properties from
objtxt (vlax-ename->vla-object (last (car txt)))
  )
  ;;Puts hard returns for text spaced greater than (* 2. hgt)
  (setq n 0)
  (foreach x txt
    (if (setq nxt (nth (setq n (1+ n)) txt))
      (if (>= (setq d (abs (- (car x) (car nxt)))) (* 2. hgt))
(setq out (cons (strcat (cadr x) "\\P\\P") out))
(setq out  (cons (cadr x) out)
      lspc (cons d lspc)
)
      )
      (setq out (cons (cadr x) out))
    )
  )
  ;;Join the text into one string
  (setq txt (apply 'strcat (reverse out)))
  ;;Insert mtext
  (setq obj (vla-addmtext
      (if (= (getvar 'cvport) 1)
(vla-get-paperspace doc)
(vla-get-modelspace doc)
      )
      (vlax-3d-point pt)
      w
      txt
    )
  )
  ;;Match properties from top text object
  (vla-put-height obj (vla-get-height objtxt))
  (vla-put-attachmentpoint obj actopleft)
  (vlax-put obj 'insertionpoint pt)
  (vla-put-rotation obj 0.0)
  (vla-put-layer obj (vla-get-layer objtxt))
  (vla-put-stylename obj (vla-get-stylename objtxt))
  (if lspc
    (vla-put-linespacingdistance
      obj
      (/ (apply '+ lspc) (length lspc))
    )
  )
  ;;Delete selected single line text
  (mapcar 'entdel elst)
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: txt2mtxt
« Reply #3 on: October 20, 2010, 03:44:18 PM »
You are awesome!

Much Thanks both!!!!!!!!!!

(Knew I should have asked yesterday)
« Last Edit: October 20, 2010, 03:56:57 PM by PHX cadie »
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #4 on: October 21, 2010, 10:11:57 AM »
Did this code work for you? I forgot to include that a portion of my code removes extra spaces ... if you don't want that, remove the portion in red below:

(strcat (rjp-removextraspaces (rjp-dxf 1 x)) " ")

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: txt2mtxt
« Reply #5 on: October 21, 2010, 03:15:52 PM »
worked great
Thx's ron!
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #6 on: October 21, 2010, 03:43:40 PM »
Glad to hear :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: txt2mtxt
« Reply #7 on: October 21, 2010, 03:49:14 PM »
Nice work Ron. Much better than my simple solution.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #8 on: October 21, 2010, 03:58:22 PM »
Thanks Alan  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: txt2mtxt
« Reply #9 on: October 28, 2010, 12:05:50 PM »
Here's my "homegrown" version:  :-)

Code: [Select]
;;; AUTHOR
;;; Copyright© 2010 Ron Perez (ronperez@gmail.com)
;;;
(defun c:t2mt (/  d     doc elst   hgt      lspc n
      nxt  obj     objtxt out   pt      ss txt
      w  x     rjp-removextraspaces  rjp-ent2obj rjp-getbbwdth
      rjp-getbbtlc     rjp-dxf
     )
  (defun rjp-removextraspaces (txt)
    (while (vl-string-search "  " txt)
      (setq txt (vl-string-subst " " "  " txt))
    )
    txt
  )
  (defun rjp-ent2obj (ent)
    (if (= (type ent) 'ename)
      (vlax-ename->vla-object ent)
      ent
    )
  )
  (defun rjp-dxf (code ent)
    (if (and ent (= (type ent) 'ename))
      (cdr (assoc code (entget ent)))
    )
  )
  (defun rjp-getbbwdth (ent / out ll ur)
    (vla-getboundingbox (rjp-ent2obj ent) 'll 'ur)
    (setq out (mapcar 'car (mapcar 'vlax-safearray->list (list ll ur))))
    (abs (- (car out) (cadr out)))
  )
  (defun rjp-getbbtlc (ent / out ll ur)
    (vla-getboundingbox (rjp-ent2obj ent) 'll 'ur)
    (setq out (mapcar 'vlax-safearray->list (list ll ur)))
    (list (caar out) (cadr (last out)) 0.0)
  )
  (if (and (setq ss (ssget ":L" (list '(0 . "text"))))
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      )
    (progn (setq elst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
;;Get widest piece of text to set mtext width
w (* 1.0125 (car (vl-sort (mapcar 'rjp-getbbwdth elst) '>)))
;;Sort text top to bottom
txt (vl-sort
 (mapcar
   '(lambda (x)
      (list
(cadr (rjp-dxf 10 x))
(strcat (rjp-removextraspaces (rjp-dxf 1 x)) " ")
x
      )
    )
   elst
 )
 (function (lambda (y1 y2) (< (car y2) (car y1))))
)
hgt (rjp-dxf 40 (last (car txt)))
pt (rjp-getbbtlc (last (car txt)))
;;Grab top text to pull properties from
objtxt (vlax-ename->vla-object (last (car txt)))
  )
  ;;Puts hard returns for text spaced greater than (* 2. hgt)
  (setq n 0)
  (foreach x txt
    (if (setq nxt (nth (setq n (1+ n)) txt))
      (if (>= (setq d (abs (- (car x) (car nxt)))) (* 2. hgt))
(setq out (cons (strcat (cadr x) "\\P\\P") out))
(setq out  (cons (cadr x) out)
      lspc (cons d lspc)
)
      )
      (setq out (cons (cadr x) out))
    )
  )
  ;;Join the text into one string
  (setq txt (apply 'strcat (reverse out)))
  ;;Insert mtext
  (setq obj (vla-addmtext
      (if (= (getvar 'cvport) 1)
(vla-get-paperspace doc)
(vla-get-modelspace doc)
      )
      (vlax-3d-point pt)
      w
      txt
    )
  )
  ;;Match properties from top text object
  (vla-put-height obj (vla-get-height objtxt))
  (vla-put-attachmentpoint obj actopleft)
  (vlax-put obj 'insertionpoint pt)
  (vla-put-rotation obj 0.0)
  (vla-put-layer obj (vla-get-layer objtxt))
  (vla-put-stylename obj (vla-get-stylename objtxt))
  (if lspc
    (vla-put-linespacingdistance
      obj
      (/ (apply '+ lspc) (length lspc))
    )
  )
  ;;Delete selected single line text
  (mapcar 'entdel elst)
    )
  )
  (princ)
)

This code work great with a routine that I am working on over at http://www.theswamp.org/index.php?topic=35426.0

However, occasionally I need to combine multiple pieces of mtext and this works as long as there is at least on regular piece of text, but I am wondering if there might be a way to modify this to work if the entire selection set is mtext?

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #10 on: October 28, 2010, 12:53:48 PM »
Just change the filter ... the way it's grabbing text now it should not get any mtext?

(setq ss (ssget ":L" (list '(0 . "*text"))))

or

(setq ss (ssget ":L" (list '(0 . "mtext,text"))))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: txt2mtxt
« Reply #11 on: October 28, 2010, 12:59:53 PM »
No, sorry, i did modify it to where it will get the mtext already, which is what I want. The problem is that if there is no regular text (i.e. all pieces of text are mtext), then it errors out before finishing the command.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #12 on: October 28, 2010, 01:22:52 PM »
No, sorry, i did modify it to where it will get the mtext already, which is what I want. The problem is that if there is no regular text (i.e. all pieces of text are mtext), then it errors out before finishing the command.

Whatever mods you did to the code broke it because I cannot replicate your problem? If you set your VLIDE to break on error you should be able to track down where the code is bonking out.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: txt2mtxt
« Reply #13 on: October 28, 2010, 02:02:45 PM »
Must remember to restart AutoCAD when things don't quite seem right....I guess something got screwy in a variable during the testing phase, restarted AutoCAD and all seems to be good now, thank you for confirming that your code was not an issue. Sorry about that.

Robert98

  • Guest
Re: txt2mtxt
« Reply #14 on: October 28, 2010, 02:42:49 PM »
Here's my "homegrown" version:  :-)

Code: [Select]
;;; AUTHOR
;;; Copyright© 2010 Ron Perez (ronperez@gmail.com)
;;;
(defun c:t2mt (/  d     doc elst   hgt      lspc n
      nxt  obj     objtxt out   pt      ss txt
      w  x     rjp-removextraspaces  rjp-ent2obj rjp-getbbwdth
      rjp-getbbtlc     rjp-dxf
     )
  (defun rjp-removextraspaces (txt)
    (while (vl-string-search "  " txt)
      (setq txt (vl-string-subst " " "  " txt))
    )
    txt
  )
  (defun rjp-ent2obj (ent)
    (if (= (type ent) 'ename)
      (vlax-ename->vla-object ent)
      ent
    )
  )
  (defun rjp-dxf (code ent)
    (if (and ent (= (type ent) 'ename))
      (cdr (assoc code (entget ent)))
    )
  )
  (defun rjp-getbbwdth (ent / out ll ur)
    (vla-getboundingbox (rjp-ent2obj ent) 'll 'ur)
    (setq out (mapcar 'car (mapcar 'vlax-safearray->list (list ll ur))))
    (abs (- (car out) (cadr out)))
  )
  (defun rjp-getbbtlc (ent / out ll ur)
    (vla-getboundingbox (rjp-ent2obj ent) 'll 'ur)
    (setq out (mapcar 'vlax-safearray->list (list ll ur)))
    (list (caar out) (cadr (last out)) 0.0)
  )
  (if (and (setq ss (ssget ":L" (list '(0 . "text"))))
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      )
    (progn (setq elst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
;;Get widest piece of text to set mtext width
w (* 1.0125 (car (vl-sort (mapcar 'rjp-getbbwdth elst) '>)))
;;Sort text top to bottom
txt (vl-sort
 (mapcar
   '(lambda (x)
      (list
(cadr (rjp-dxf 10 x))
(strcat (rjp-removextraspaces (rjp-dxf 1 x)) " ")
x
      )
    )
   elst
 )
 (function (lambda (y1 y2) (< (car y2) (car y1))))
)
hgt (rjp-dxf 40 (last (car txt)))
pt (rjp-getbbtlc (last (car txt)))
;;Grab top text to pull properties from
objtxt (vlax-ename->vla-object (last (car txt)))
  )
  ;;Puts hard returns for text spaced greater than (* 2. hgt)
  (setq n 0)
  (foreach x txt
    (if (setq nxt (nth (setq n (1+ n)) txt))
      (if (>= (setq d (abs (- (car x) (car nxt)))) (* 2. hgt))
(setq out (cons (strcat (cadr x) "\\P\\P") out))
(setq out  (cons (cadr x) out)
      lspc (cons d lspc)
)
      )
      (setq out (cons (cadr x) out))
    )
  )
  ;;Join the text into one string
  (setq txt (apply 'strcat (reverse out)))
  ;;Insert mtext
  (setq obj (vla-addmtext
      (if (= (getvar 'cvport) 1)
(vla-get-paperspace doc)
(vla-get-modelspace doc)
      )
      (vlax-3d-point pt)
      w
      txt
    )
  )
  ;;Match properties from top text object
  (vla-put-height obj (vla-get-height objtxt))
  (vla-put-attachmentpoint obj actopleft)
  (vlax-put obj 'insertionpoint pt)
  (vla-put-rotation obj 0.0)
  (vla-put-layer obj (vla-get-layer objtxt))
  (vla-put-stylename obj (vla-get-stylename objtxt))
  (if lspc
    (vla-put-linespacingdistance
      obj
      (/ (apply '+ lspc) (length lspc))
    )
  )
  ;;Delete selected single line text
  (mapcar 'entdel elst)
    )
  )
  (princ)
)
Hi ronjonp
I made a sample with 12 numbers and run your codes and for selection , I used a fence so your codes act on separate text correctly but put all of them at a column in right side of screen , like this :
145
12
178
10
.
.
.
I don't know , I'm a bad user or your routine  should acts this way . please tell me if I want mtext made instead one of them or at least around them , what must I do ? I don't work whit vlisp codes and most importantly it I need to your permission.
Until after bye :realmad:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: txt2mtxt
« Reply #15 on: October 28, 2010, 03:18:42 PM »
Robert,
Please post a sample DWG like the one you are working with.

I'm moving this thread to the lisp forum.

Thanks
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

jaydee

  • Guest
Re: txt2mtxt
« Reply #16 on: October 28, 2010, 09:04:45 PM »
Hi.
Just wondering if someone be able to take this further and convert it to individual groups of MTEXT, instead of lumping all selected text into one mtext.
ie.
say i make a mtext with multiple lines, then copy it a few times ramdomly around the screen, then explode all the mtext. And now try  to select all the text and still be able to convert it back to individual mtext (ie. convert it to way it was prior to exploding).

Thankyou

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: txt2mtxt
« Reply #17 on: October 28, 2010, 11:18:32 PM »
That might be difficult if there is no clear rules for determining how to separate each mtext.
Why would you explode mtext? And if there was a good reason then why would you need to put it together again.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

jaydee

  • Guest
Re: txt2mtxt
« Reply #18 on: October 29, 2010, 12:01:27 AM »
Hi CAB.
Its just an example to show how i would like to have a routine to convert text to mtext. (i have seen lisp that either convert all select text to a single mtext or convert every single line text to mtext as separate item).
So often we need to update an old drawings or drawings from others that only used the old Dtext, but those text still stack up as paragraphs such as scattered inplace notes on the drawing. I know i could used xpress tool to convert these, but if the drawing consisted of hundreds of dtext paragaphs, then it would be a very tedious selection.

I think the rules is if the dtext is 2.5mm height, then if the next text line is between 3&5mm below it (same x coordinates), then i would assume its the same paragraph, therefore group these together as Mtext. and move on to convert the next group of text with the same rule.

Thankyou

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: txt2mtxt
« Reply #19 on: October 29, 2010, 08:56:00 AM »
OK I see what you meant to do. You may find this routine interesting.
http://www.theswamp.org/index.php?topic=2133.msg27500#msg27500
It detects overlap but may be converted to detect adjacent mtext.


Later.....
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

jaydee

  • Guest
Re: txt2mtxt
« Reply #20 on: November 01, 2010, 06:39:44 PM »
Thanks CAB
I will look into it, but looks like its to deep for me to make use of it for now.
cheers

jmcshane

  • Newt
  • Posts: 83
Re: txt2mtxt
« Reply #21 on: November 02, 2010, 06:03:15 AM »
Nice work Ron. Much better than my simple solution.
Nice work Gentlemen,
but Alan, your simple code is exactly what I have been looking for.

Many thanks to you both.

John
John.

Civil 3D 2021. Windows 10

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: txt2mtxt
« Reply #22 on: November 02, 2010, 12:17:18 PM »
Nice work Ron. Much better than my simple solution.
Nice work Gentlemen,
but Alan, your simple code is exactly what I have been looking for.

Many thanks to you both.

John
Well then, enjoy.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #23 on: November 02, 2010, 04:53:27 PM »
Hi.
Just wondering if someone be able to take this further and convert it to individual groups of MTEXT, instead of lumping all selected text into one mtext.
ie.
say i make a mtext with multiple lines, then copy it a few times ramdomly around the screen, then explode all the mtext. And now try  to select all the text and still be able to convert it back to individual mtext (ie. convert it to way it was prior to exploding).

Thankyou

Had a bit of free time today. This will sort by common X values (fuzz of text height) and group the text. It does not break up text in the same column if the spacing is greater than 2X the height.

Have fun :)

Code: [Select]
;;; AUTHOR
;;; Copyright© 2010 Ron Perez (ronperez@gmail.com)
;;; 11.02.2010 added grouping text by X values
(defun c:t2mt (/   rjp-removextraspaces rjp-ent2obj       rjp-getbbwdth
       rjp-getbbtlc      rjp-dxf d    doc       elst hgt
       i   n      nxt obj    otxt       out pt
       ss   txt      w x    x_sort     y
      )
  (defun rjp-removextraspaces (txt)
    (while (vl-string-search "  " txt) (setq txt (vl-string-subst " " "  " txt)))
    txt
  )
  (defun rjp-ent2obj (ent)
    (if (= (type ent) 'ename)
      (vlax-ename->vla-object ent)
      ent
    )
  )
  (defun rjp-dxf (code ent)
    (if (and ent (= (type ent) 'ename))
      (cdr (assoc code (entget ent)))
    )
  )
  (defun rjp-getbb (ent / ll ur)
    (vla-getboundingbox (rjp-ent2obj ent) 'll 'ur)
    (mapcar 'vlax-safearray->list (list ll ur))
  )
  (defun rjp-getbbwdth (ent / out)
    (setq out (mapcar 'car (rjp-getbb (rjp-ent2obj ent))))
    (abs (- (car out) (cadr out)))
  )
  (defun rjp-getbbtlc (ent / out)
    (setq out (rjp-getbb (rjp-ent2obj ent)))
    (list (caar out) (cadr (last out)) 0.0)
  )
  (if (and (setq ss (ssget ":L" (list '(0 . "text"))))
   (setq doc (vla-get-activedocument (vlax-get-acad-object)))
   ;;list as X Y TEXT ENAME
   (setq elst (mapcar '(lambda (x)
(list (car (rjp-dxf 10 x))
       (cadr (rjp-dxf 10 x))
       (strcat (rjp-removextraspaces (rjp-dxf 1 x)) " ")
       x
)
       )
      (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      )
   )
      )
    (progn
      ;;Sort top to bottom
      (setq elst (vl-sort elst '(lambda (y1 y2) (> (cadr y1) (cadr y2)))))
      ;;Group by x values using text height as fuzz value
      (while (setq i (car elst))
(setq y (vl-remove-if-not '(lambda (x) (equal (car i) (car x) (rjp-dxf 40 (last i)))) elst))
(mapcar '(lambda (x) (setq elst (vl-remove x elst))) y)
(setq x_sort (cons y x_sort))
      )
      (foreach item x_sort
(setq ;;Get widest piece of text to set mtext width
      w    (* 1.0125 (car (vl-sort (mapcar 'rjp-getbbwdth (mapcar 'last item)) '>)))
      hgt  (rjp-dxf 40 (last (car item)))
      pt   (rjp-getbbtlc (last (car item)))
      ;;Grab top text to pull properties from
      otxt (vlax-ename->vla-object (last (car item)))
)
;;Puts hard returns for text spaced greater than (* 2. hgt)
(setq n 0)
(foreach x item
  (if (setq nxt (nth (setq n (1+ n)) item))
    (if (>= (setq d (abs (- (cadr x) (cadr nxt)))) (* 2. hgt))
      (setq out (cons (strcat (caddr x) "\\P\\P") out))
      (setq out (cons (caddr x) out))
    )
    (setq out (cons (caddr x) out))
  )
)
;;Join the text into one string
(setq txt (apply 'strcat (reverse out)))
;;Insert mtext
(setq obj (vla-addmtext
    (if (= (getvar 'cvport) 1)
      (vla-get-paperspace doc)
      (vla-get-modelspace doc)
    )
    (vlax-3d-point pt)
    w
    txt
  )
      txt nil
      out nil
)
;;Match properties from top text object
(vla-put-height obj (vla-get-height otxt))
(vla-put-attachmentpoint obj actopleft)
(vlax-put obj 'insertionpoint pt)
(vla-put-rotation obj 0.0)
(vla-put-layer obj (vla-get-layer otxt))
(vla-put-stylename obj (vla-get-stylename otxt))
;;Delete selected single line text
(mapcar 'entdel (mapcar 'last item))
      )
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: txt2mtxt
« Reply #24 on: November 02, 2010, 05:13:57 PM »
Very nice Ron. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #25 on: November 02, 2010, 05:22:07 PM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: txt2mtxt
« Reply #26 on: November 02, 2010, 05:24:10 PM »
Daaaaamn, nice work Ron.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #27 on: November 02, 2010, 05:34:35 PM »
Daaaaamn, nice work Ron.

Thanks Alan  :-D Hopefully some people can get some use out of it.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jaydee

  • Guest
Re: txt2mtxt
« Reply #28 on: November 02, 2010, 08:10:01 PM »
Very nice RONJONP.
"It does not break up text in the same column if the spacing is greater than 2X the height."

Is this something that you might be able to looking into in the future. Really appreciated if this last puzzle could be solve to covert paragraphs in the same column into separate mtext paragraph.

Thankyou verymuch.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #29 on: November 04, 2010, 12:45:33 PM »
Very nice RONJONP.
"It does not break up text in the same column if the spacing is greater than 2X the height."

Is this something that you might be able to looking into in the future. Really appreciated if this last puzzle could be solve to covert paragraphs in the same column into separate mtext paragraph.

Thankyou verymuch.

I'll try and get to it next week.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7526
Re: txt2mtxt
« Reply #30 on: November 05, 2010, 03:32:05 PM »
Very nice RONJONP.
"It does not break up text in the same column if the spacing is greater than 2X the height."

Is this something that you might be able to looking into in the future. Really appreciated if this last puzzle could be solve to covert paragraphs in the same column into separate mtext paragraph.

Thankyou verymuch.

I'll try and get to it next week.

Got to it early :) ... I posted the code here:

http://www.theswamp.org/index.php?topic=35607.0

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC