Here's a modification of my code that @hak_vz posted, to allow Text or Mtext and to ask the User for the character at which to split the original. Lightly tested in your sample drawing. As in its original version, it actually splits the object into two parts, but it could be made to only find the position of the separator character instead [within a small variability].
(defun C:ST2C ; = Split Text/Mtext into 2 pieces around specified Character
;; starting from top-/middle-/bottom-LEFT justifications,
(/ bbwid char ss n txt txto1 txtinit inspt rot wid charp txto2)
(defun bbwid (obj / minpt maxpt)
(vla-getboundingbox obj 'minpt 'maxpt)
(- (car (vlax-safearray->list maxpt)) (car (vlax-safearray->list minpt)))
); defun -- bbwid
(while
(not
(and
(setq char (getstring "\nSingle character for break location: "))
(= (strlen char) 1)
); and
); not
(prompt "\nMust be one character only.")
); while
(if (setq ss (ssget ":L" (list '(0 . "*TEXT") (cons 1 (strcat "*" char "*"))))); Text or Mtext
(repeat (setq n (sslength ss))
(setq
txt (ssname ss (setq n (1- n))); entity name [for Copy below]
txto1 (vlax-ename->vla-object txt); as VLA object
txtinit (vla-get-TextString txto1); initial text content
inspt (vlax-get txto1 'InsertionPoint)
rot (vla-get-rotation txto1)
wid
(if (= (vla-get-ObjectName txto1) "AcDbText")
(bbwid txto1); then [Text]
(cdr (assoc 42 (entget txt))); [not available as VLA property]; else [Mtext]
); if
charp (vl-string-search char txtinit); character position
); setq
(command "_.copy" txt "" '(0 0) "")
(setq txto2 (vlax-ename->vla-object (entlast)))
(vla-put-TextString txto1 (substr txtinit 1 charp))
; string before designated character plus one space
(vla-put-TextString txto2 (substr txtinit (1+ charp))); string from designated character
(redraw txt); needed to get reduced widths correctly [otherwise uses original]
(setq
wid ; reduced width of original to before character
(if (= (vla-get-ObjectName txto1) "AcDbText")
(bbwid txto1); then
(cdr (assoc 42 (entget txt))); else
); if
); setq
(vlax-put txto2 'insertionpoint (polar inspt rot (+ wid (/ (vla-get-Height txto1) 4))))
; move over by reduced first-part width plus 1/4 of height
); repeat
); if
(princ)
); defun
The splitting character is case-sensitive. If there's more than one occurrence of that, it splits it at the first one only.
It can be enhanced to do things like remember your specified character to offer as default on subsequent use, and of course for the usual stuff -- *error* handling, Undo begin/end wrapping, etc. But first see whether it does what you want.
Note that it's designed for left-justified objects, and for zero [or, if you want, 180°] rotation. It could be made to account for different justifications. Different rotations would be more complicated, since it uses the bounding box approach -- it might be necessary to align the UCS with the object. And it can give different results than expected if Mtext has multiple lines.
The positioning of the second part can shift a little, depending on the font. You can change the amount of added move-over width if 1/4 of the height doesn't give you good results.
Kent Cooper, AIA