I am lifting mtext from a drawing and then working with the result. For some reason the "\\pxi-" at the begining of the string I am lifting is converting to "\ pxi-" when worked with as a string in vb.net. The result is this, when I apply the string back to mtext I get a bunch of messed up formatting codes at the begining rather than a formatted piece of text.
This seems to be related to the "\\" Is this automatically getting modified by vb or autocad when I pull the source text?
Add to directives region:
then split string using Regex or usual way
Dim str AsString = Regex.Split("\pxi;here is your mtext string...", ";")(1)
this will cut your formatting prefix
Unless it is formatted with fonts, etc.... which most people dislike and reason for this method, but for basic formatting you can use the Mtext.Text property modify then set it to the MText.Contents property.
Here is a litte one converted to VB that gets rid of all font and size formatting but will keep all 'returns', it has some extensions method used but easy to tell what it is doing.
Public Sub STRIPMTXT() Using trx As Transaction = Db.TransactionManager.StartTransaction() Dim btr As BlockTableRecord = Db.CurrentSpace() Dim mtxts = btr.GetObjectsOfType(Of MText)(OpenMode.ForWrite) For Each mtxt As MText In mtxts mtxt.Contents = mtxt.Text Next trx.Commit() End Using End Sub
Thanks for your help guys....Jeff I think I'm going to go with your plan, although I was kinda hoping I could easily maintain the formatting codes. After I get this round of programing done I will probably modify it to do the regex split and then put the formatting back when I am done working with the text, if that is possible due to the double backslash issue.
Access a broad range of knowledge to help get the most out of your products and services.