<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help me with mtexts and text string in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194136#M20822</link>
    <description>Yeah, thanks Bryco&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
    <pubDate>Mon, 03 Mar 2008 12:33:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-03-03T12:33:21Z</dc:date>
    <item>
      <title>Help me with mtexts and text string</title>
      <link>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194133#M20819</link>
      <description>I want to iterate through the mtexts of a given drawing and export them to Excel.suppose that there is an mtext in the drawing named mtextobj in which "sample" is written in the first line and "note" is written in the 2nd.this would be read as "sample note". i use TextString property:&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
Dim mtextobj As AcadMText&lt;BR /&gt;
MsgBox mtextobj .TextString&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
and autocad returns "sample\Pnote". this is appropriate for me.&lt;BR /&gt;
the problem is when text formatting of this mtext is changed.for example if i double click on the mtext and in the Text Formatting box change the color to red,autocad returns&lt;BR /&gt;
{\C1;sample\Pnote}&lt;BR /&gt;
&lt;BR /&gt;
or if i change the font to verdana it gives&lt;BR /&gt;
{\fVerdana|b0|i0|c0|p34;sample\fVerdana|b0|i0|c178|p34;\P\fVerdana|b0|i0|c0|p34;note}&lt;BR /&gt;
&lt;BR /&gt;
How can i access to the real content inside the mtext? and get rid of this string which is merged with text formatting data?&lt;BR /&gt;
any help is highly appreciated...

Message was edited by: arman88</description>
      <pubDate>Sun, 02 Mar 2008 12:30:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194133#M20819</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-02T12:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with mtexts and text string</title>
      <link>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194134#M20820</link>
      <description>Try this one&lt;BR /&gt;
&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
' written by Bryco&lt;BR /&gt;
&lt;BR /&gt;
Function UnformatMtext(S As String) As String&lt;BR /&gt;
    &lt;BR /&gt;
    Dim P1 As Integer&lt;BR /&gt;
    Dim P2 As Integer, P3 As Integer&lt;BR /&gt;
    Dim intStart As Integer&lt;BR /&gt;
    Dim strCom As String&lt;BR /&gt;
    Dim strReplace As String&lt;BR /&gt;
    &lt;BR /&gt;
    Debug.Print S&lt;BR /&gt;
 &lt;BR /&gt;
    Select Case Left(S, 4)&lt;BR /&gt;
        Case "\A0;", "\A1;", "\A2;"&lt;BR /&gt;
            S = Mid(S, P1 + 5)&lt;BR /&gt;
    End Select&lt;BR /&gt;
    intStart = 1&lt;BR /&gt;
    Do&lt;BR /&gt;
        P1 = InStr(S, "%%")&lt;BR /&gt;
        If P1 = 0 Then&lt;BR /&gt;
            Exit Do&lt;BR /&gt;
        Else&lt;BR /&gt;
            Select Case Mid(S, P1 + 2, 1)&lt;BR /&gt;
            Case "P"&lt;BR /&gt;
                S = Replace(S, "%%P", "+or-")&lt;BR /&gt;
            Case "D"&lt;BR /&gt;
                S = Replace(S, "%%D", " deg")&lt;BR /&gt;
            End Select&lt;BR /&gt;
        End If&lt;BR /&gt;
    Loop&lt;BR /&gt;
 &lt;BR /&gt;
    Do&lt;BR /&gt;
        P1 = InStr(intStart, S, "\", vbTextCompare)&lt;BR /&gt;
        If P1 = 0 Then Exit Do&lt;BR /&gt;
        strCom = Mid(S, P1, 2)&lt;BR /&gt;
        Select Case strCom&lt;BR /&gt;
            Case "\p"&lt;BR /&gt;
                P2 = InStr(1, S, ";")&lt;BR /&gt;
                S = Mid(S, P2 + 1)&lt;BR /&gt;
            Case "\A", "\C", "\f", "\F", "\H", "\Q", "\T", "\W"&lt;BR /&gt;
                P2 = InStr(P1 + 2, S, ";", vbTextCompare)&lt;BR /&gt;
                P3 = InStr(P1 + 2, S, strCom, vbTextCompare)&lt;BR /&gt;
                If P3 = 0 Then&lt;BR /&gt;
                    S = Left(S, P1 - 1) &amp;amp; Mid(S, P2 + 1)&lt;BR /&gt;
                End If&lt;BR /&gt;
                Do While P3 &amp;gt; 0&lt;BR /&gt;
                    P2 = InStr(P3, S, ";", vbTextCompare)&lt;BR /&gt;
                    S = Left(S, P3 - 1) &amp;amp; Mid(S, P2 + 1)&lt;BR /&gt;
                    'Debug.Print s, strCom&lt;BR /&gt;
                    P3 = InStr(1, S, strCom, vbTextCompare)&lt;BR /&gt;
                Loop&lt;BR /&gt;
                    's = Left(s, P3 - 1) &amp;amp; mid(s, P3 + 1)&lt;BR /&gt;
            'Case "\L", "\O"&lt;BR /&gt;
                'Dim strLittle As String&lt;BR /&gt;
                'strLittle = LCase(strCom)&lt;BR /&gt;
                'P2 = InStr(P1 + 2, S, strLittle, vbTextCompare)&lt;BR /&gt;
                'S = Left(S, P1 - 1) &amp;amp; Mid(S, P1 + 2, P2 - (P1 + 2)) &amp;amp; Mid(S, P2 + 2)&lt;BR /&gt;
'//============== fixed by fla_2&lt;BR /&gt;
'// example {\fArial|b1|i0|c0|p34;\LGENERAL NOTES :}&lt;BR /&gt;
Case "\L", "\O"&lt;BR /&gt;
Dim strLittle As String&lt;BR /&gt;
strLittle = LCase(strCom)&lt;BR /&gt;
P2 = InStr(P1 + 2, S, strLittle, vbTextCompare)&lt;BR /&gt;
If P2 = 0 Then&lt;BR /&gt;
S = Left(S, P1 - 1) &amp;amp; Mid(S, P1 + 2)&lt;BR /&gt;
Else&lt;BR /&gt;
S = Left(S, P1 - 1) &amp;amp; Mid(S, P1 + 2, P2 - (P1 + 2)) &amp;amp; Mid(S, P2 + 2)&lt;BR /&gt;
End If&lt;BR /&gt;
'//==============&lt;BR /&gt;
            Case "\S"&lt;BR /&gt;
                P2 = InStr(P1 + 2, S, ";", vbTextCompare)&lt;BR /&gt;
                P3 = InStr(P1 + 2, S, "/", vbTextCompare)&lt;BR /&gt;
                If P3 = 0 Or P3 &amp;gt; P2 Then&lt;BR /&gt;
                    P3 = InStr(P1 + 2, S, "#", vbTextCompare)&lt;BR /&gt;
                End If&lt;BR /&gt;
                If P3 = 0 Or P3 &amp;gt; P2 Then&lt;BR /&gt;
                    P3 = InStr(P1 + 2, S, "^", vbTextCompare)&lt;BR /&gt;
                End If&lt;BR /&gt;
                S = Left(S, P1 - 1) &amp;amp; Mid(S, P1 + 2, P3 - (P1 + 2)) _&lt;BR /&gt;
                        &amp;amp; "/" &amp;amp; Mid(S, P3 + 1, (P2) - (P3 + 1)) &amp;amp; Mid(S, P2 + 1)&lt;BR /&gt;
                        &lt;BR /&gt;
            Case "\U"&lt;BR /&gt;
                strLittle = Mid(S, P1 + 3, 4)&lt;BR /&gt;
                Debug.Print strLittle&lt;BR /&gt;
                Select Case strLittle&lt;BR /&gt;
                    Case "2248"&lt;BR /&gt;
                        strReplace = "ALMOST EQUAL"&lt;BR /&gt;
                    Case "2220"&lt;BR /&gt;
                        strReplace = "ANGLE"&lt;BR /&gt;
                    Case "2104"&lt;BR /&gt;
                        strReplace = "CENTER LINE"&lt;BR /&gt;
                    Case "0394"&lt;BR /&gt;
                        strReplace = "DELTA"&lt;BR /&gt;
                    Case "0278"&lt;BR /&gt;
                        strReplace = "ELECTRIC PHASE"&lt;BR /&gt;
                    Case "E101"&lt;BR /&gt;
                        strReplace = "FLOW LINE"&lt;BR /&gt;
                    Case "2261"&lt;BR /&gt;
                        strReplace = "IDENTITY"&lt;BR /&gt;
                    Case "E200"&lt;BR /&gt;
                        strReplace = "INITIAL LENGTH"&lt;BR /&gt;
                    Case "E102"&lt;BR /&gt;
                        strReplace = "MONUMENT LINE"&lt;BR /&gt;
                    Case "2260"&lt;BR /&gt;
                        strReplace = "NOT EQUAL"&lt;BR /&gt;
                    Case "2126"&lt;BR /&gt;
                        strReplace = "OHM"&lt;BR /&gt;
                    Case "03A9"&lt;BR /&gt;
                        strReplace = "OMEGA"&lt;BR /&gt;
                    Case "214A"&lt;BR /&gt;
                        strReplace = "PROPERTY LINE"&lt;BR /&gt;
                    Case "2082"&lt;BR /&gt;
                        strReplace = "SUBSCRIPT2"&lt;BR /&gt;
                    Case "00B2"&lt;BR /&gt;
                        strReplace = "SQUARED"&lt;BR /&gt;
                    Case "00B3"&lt;BR /&gt;
                        strReplace = "CUBED"&lt;BR /&gt;
 &lt;BR /&gt;
                End Select&lt;BR /&gt;
                S = Replace(S, "\U+" &amp;amp; strLittle, strReplace)&lt;BR /&gt;
                &lt;BR /&gt;
            Case "\~"&lt;BR /&gt;
                S = Replace(S, "\~", " ")&lt;BR /&gt;
                &lt;BR /&gt;
            Case "\\"&lt;BR /&gt;
                intStart = P1 + 2&lt;BR /&gt;
                S = Replace(S, "\\", "\")&lt;BR /&gt;
                GoTo Selectagain&lt;BR /&gt;
                &lt;BR /&gt;
            Case "\P"&lt;BR /&gt;
                intStart = P1 + 1&lt;BR /&gt;
                GoTo Selectagain&lt;BR /&gt;
            Case Else&lt;BR /&gt;
                Exit Do&lt;BR /&gt;
        End Select&lt;BR /&gt;
Selectagain:&lt;BR /&gt;
    Loop&lt;BR /&gt;
    &lt;BR /&gt;
   Do&lt;BR /&gt;
        P1 = InStr(1, S, "\P", vbTextCompare)&lt;BR /&gt;
        If P1 = 0 Then&lt;BR /&gt;
            Exit Do&lt;BR /&gt;
        Else&lt;BR /&gt;
            S = Left(S, P1 - 1) &amp;amp; vbCrLf &amp;amp; Mid(S, P1 + 2)&lt;BR /&gt;
        End If&lt;BR /&gt;
    Loop&lt;BR /&gt;
    For intStart = 0 To 1&lt;BR /&gt;
        If intStart = 0 Then&lt;BR /&gt;
            strCom = "}"&lt;BR /&gt;
        Else&lt;BR /&gt;
            strCom = "{"&lt;BR /&gt;
        End If&lt;BR /&gt;
        P2 = InStr(1, S, strCom)&lt;BR /&gt;
        &lt;BR /&gt;
        Do While P2 &amp;gt; 0&lt;BR /&gt;
            S = Left(S, P2 - 1) &amp;amp; Mid(S, P2 + 1)&lt;BR /&gt;
            P2 = InStr(1, S, strCom)&lt;BR /&gt;
        Loop&lt;BR /&gt;
    Next intStart&lt;BR /&gt;
    &lt;BR /&gt;
    &lt;BR /&gt;
 UnformatMtext = S&lt;BR /&gt;
 &lt;BR /&gt;
End Function&lt;BR /&gt;
 &lt;BR /&gt;
Sub Testmt()&lt;BR /&gt;
    Dim Mt As AcadMText, V As Variant&lt;BR /&gt;
    ThisDrawing.Utility.GetEntity Mt, V, "Pick an Mtext:"&lt;BR /&gt;
    Debug.Print Mt.textString&lt;BR /&gt;
    Mt.textString = UnformatMtext(Mt.textString)&lt;BR /&gt;
    MsgBox Mt.textString&lt;BR /&gt;
End Sub</description>
      <pubDate>Sun, 02 Mar 2008 15:21:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194134#M20820</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-02T15:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with mtexts and text string</title>
      <link>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194135#M20821</link>
      <description>WOWWWWW . Thanksssss a lot! That works pretty well. I used that function and this code:&lt;BR /&gt;
&lt;BR /&gt;
Sub Testmt()&lt;BR /&gt;
Dim Mt As AcadMText&lt;BR /&gt;
Dim obj As AcadObject&lt;BR /&gt;
For Each obj In ThisDrawing.ModelSpace&lt;BR /&gt;
    If obj.ObjectName = "AcDbMText" Then&lt;BR /&gt;
        Set Mt = obj&lt;BR /&gt;
        Debug.Print Mt.TextString&lt;BR /&gt;
        Mt.TextString = UnformatMtext(Mt.TextString)&lt;BR /&gt;
    End If&lt;BR /&gt;
Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
This way all mtexts in the drawing corrected in the way i want.It dosn't change boundaries, size , insertion point,attachmentpoint and layer of mtexts. right? because I want those properties to be left original.I checked and it seems ok.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again Fatty!  and Thanks Bryco!</description>
      <pubDate>Mon, 03 Mar 2008 11:39:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194135#M20821</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-03T11:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with mtexts and text string</title>
      <link>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194136#M20822</link>
      <description>Yeah, thanks Bryco&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Mon, 03 Mar 2008 12:33:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194136#M20822</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-03T12:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help me with mtexts and text string</title>
      <link>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194137#M20823</link>
      <description>i found lisp code for that too.&lt;BR /&gt;
try .lsp and .dcl in the attachments</description>
      <pubDate>Tue, 04 Mar 2008 09:45:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/help-me-with-mtexts-and-text-string/m-p/2194137#M20823</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-04T09:45:11Z</dc:date>
    </item>
  </channel>
</rss>

