<?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: Finding &amp;amp; Replacing Mtext in a Block using VB.net? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4661429#M46801</link>
    <description>&lt;P&gt;mzakiralam&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I must be Dumb as a sack of dirty diapers &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked your code over and found similar code in the "MyPlugin" namespace. I added the handlers to the same location as the other handlers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added the Sub ReplaceMtextinTitleBlock (with minor changes to the Sze Dim) to the same namespace. All seems syntax correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still don't know how to get this Sub to "Fire" when the Form frmTitleBlockEditor is loaded? Attached is the MyPlugin code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports System
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput

' This line is not mandatory, but improves loading performances
&amp;lt;Assembly: ExtensionApplication(GetType(TitleBlockEditorNET.MyPlugin))&amp;gt; 

Namespace TitleBlockEditorNET

   ' This class is instantiated by AutoCAD once and kept alive for the 
   ' duration of the session. If you don't do any one time initialization 
   ' then you should remove this class.
   Public Class MyPlugin
      Implements IExtensionApplication
      Dim WithEvents AcadAPP As Application
      Dim WithEvents AcadDWG As Document
      Dim WithEvents AcadDM As DocumentCollection = Application.DocumentManager()

        Private _sIdleHandlerOwner As String
        Private _eDocumentLockMode As DocumentLockMode
        Dim _bTitleBlockDoubleClicked As Boolean


      Public Sub Initialize() Implements IExtensionApplication.Initialize

         'Declarations
         '============
         Dim oDwg As Document = Application.DocumentManager.MdiActiveDocument
         Dim oDM As DocumentCollection = Application.DocumentManager()
         Dim oDB As Database = oDwg.Database
            Dim oEd As Editor = oDwg.Editor

            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
            ed.WriteMessage("DLL loading and document created handler added")
            ''AddHandler Application.DocumentManager.DocumentCreated, AddressOf ReplaceMtextinTitleBlock

         '=========
         'Turn on application-level event handlers
            AddHandler Application.DocumentManager.DocumentCreated, AddressOf AcadDocumentCreated
            AddHandler Application.DocumentManager.DocumentCreated, AddressOf ReplaceMtextinTitleBlock
            AddHandler Application.DocumentManager.DocumentActivated, AddressOf AcadDocumentActivated
            ''AddHandler Application.DocumentManager.DocumentCreated, AddressOf ReplaceMtextinTitleBlock()
         AddHandler Application.BeginDoubleClick, AddressOf AcadBeginDoubleClick
         'AddHandler Application.Idle, AddressOf AcadIdle

         'Turn on document-level event handlers for current drawing
         AddHandler oDM.DocumentLockModeChanged, AddressOf AcadDocumentLockModeChanged
         AddHandler oDwg.CommandEnded, AddressOf AcadDocumentCommandEnded
         AddHandler oDwg.CommandCancelled, AddressOf AcadDocumentCommandCanceled
            AddHandler oDwg.EndDwgOpen, AddressOf AcadEndDwgOpen

         'AddHandler oEd.SelectionAdded, AddressOf AcadSelectionAdded







         'Ensure FirstEnergy UI elements are loaded
            'Call modAppCommands.FECUI()
         Call modAppCommands.FECONTEXT()

      End Sub

      Public Sub Terminate() Implements IExtensionApplication.Terminate

         ' Do plug-in application clean up here

      End Sub

      Private Sub AcadDocumentCreated(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DocumentCollectionEventArgs)

         'Declarations
         '============
         Dim oDwg As Document
         Dim oDB As Database = Application.DocumentManager.MdiActiveDocument.Database
         Dim oEd As Editor
         Dim oDM As DocumentCollection = Application.DocumentManager()


         'Begin Sub
         '=========
         oDwg = Application.DocumentManager.MdiActiveDocument
         If oDwg.IsReadOnly Then
            MsgBox("Drawing is read-only.")
            Return
         End If

         oEd = oDwg.Editor

         'Turn on event handlers
         AcadDWG = e.Document

         AddHandler oDM.DocumentLockModeChanged, AddressOf AcadDocumentLockModeChanged
         AddHandler oDwg.CommandEnded, AddressOf AcadDocumentCommandEnded
         AddHandler oDwg.CommandCancelled, AddressOf AcadDocumentCommandCanceled
         AddHandler oDwg.EndDwgOpen, AddressOf AcadEndDwgOpen
         'AddHandler oEd.SelectionAdded, AddressOf AcadSelectionAdded


         'Ensure FirstEnergy UI elements are loaded
         'Call modAppCommands.FECUI()
         'Call modAppCommands.FECONTEXT()

      End Sub

      Sub AcadDocumentCommandEnded(ByVal sender As Object, ByVal e As CommandEventArgs)

         'Debug.Print(e.GlobalCommandName.ToString)
         'If g_bTitleBlockDoubleClicked Then
         '   Try
         '      Dim frm As New frmTitleBlockEditor
         '      Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(frm)

         '   Catch ex As Autodesk.AutoCAD.Runtime.Exception
         '      MsgBox(ex.Message.ToString)

         '   End Try
         'End If

      End Sub

        Sub AcadDocumentCommandCanceled()
            Debug.Print("Canceled")
        End Sub



        Public Sub ReplaceMtextinTitleBlock(ByVal senderObj As Object, ByVal docColDocActEvtArgs As DocumentCollectionEventArgs)
            'put your mtext replacing code
            Dim doc As Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim Ed As Editor = doc.Editor
            Dim mtextClass As RXClass = RXClass.GetClass(GetType(MText))
            Dim Sze As String = FirstEnergy.AutoCADFunctions.GetTitleBlockName



            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = DirectCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                If Not bt.Has(Sze) Then
                    ''Application.ShowAlertDialog("Block" &amp;amp; Sze.ToString &amp;amp; "Not Found")
                    Return
                End If
                Dim btr As BlockTableRecord = DirectCast(tr.GetObject(bt(Sze), OpenMode.ForRead), BlockTableRecord)
                For Each id As ObjectId In btr
                    If id.ObjectClass = mtextClass Then
                        Dim mtext As MText = DirectCast(tr.GetObject(id, OpenMode.ForRead), MText)
                        If mtext.Contents.Contains(" CORP.") Then
                            mtext.UpgradeOpen()
                            mtext.Contents = mtext.Contents.Replace(" CORP.", ", LLC")
                        End If
                    End If
                Next
                tr.Commit()
            End Using
            Ed.Regen()


        End Sub


        Sub AcadBeginDoubleClick(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.BeginDoubleClickEventArgs)

            Dim oDwg As Document = Application.DocumentManager.MdiActiveDocument
            Dim oEd As Editor = oDwg.Editor
            Dim oPSR As PromptSelectionResult = oEd.SelectImplied
            Dim oSS As SelectionSet = oPSR.Value
            Dim oArrayOIDs() As ObjectId
            Dim oEnt As Entity
            Dim oBlkRef As BlockReference

            If oSS Is Nothing Then
                Return
            End If

            Dim tr As Transaction = oDwg.TransactionManager.StartTransaction
            Using tr
                'Process selection set
                oArrayOIDs = oSS.GetObjectIds()
                For Each oOID In oArrayOIDs
                    oEnt = oOID.GetObject(OpenMode.ForRead)
                    If TypeOf oEnt Is BlockReference Then
                        oBlkRef = CType(oEnt, BlockReference)
                        Select Case oBlkRef.Name
                            Case "A-Size"
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                            Case "B-Size"
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                            Case "C-Size"
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                            Case "D-Size"
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                            Case "E-Size"
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                            Case "F-Size"
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                            Case "G-Size"
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                            Case "X-Size"
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                            Case Else
                                _sIdleHandlerOwner = "AcadBeginDoubleClick"

                        End Select
                        Debug.Print(oBlkRef.Name)
                    End If
                Next oOID
            End Using


        End Sub

        Sub AcadIdle(ByVal sender As Object, ByVal e As System.EventArgs)

            Debug.Print("IDLE")
            RemoveHandler Application.Idle, AddressOf AcadIdle


            Dim oDwg As Document = Application.DocumentManager.MdiActiveDocument

            'Make sure FirstEnergy CUIx file is loaded on startup, then turn of handler
            If Not modAcadUI.IsPartialCuiFileLoaded("FE2011") Then

                Dim iFILEDIA As Integer = Application.GetSystemVariable("FILEDIA")
                Dim iCMDECHO As Integer = Application.GetSystemVariable("CMDECHO")
                Application.SetSystemVariable("CMDECHO", 0)

                Application.SetSystemVariable("FILEDIA", iFILEDIA)
                Application.SetSystemVariable("CMDECHO", iCMDECHO)

                'Call modAcadUI.LoadPartialCuiFile(oDwg, g_sSupportFilePath &amp;amp; "\FirstEnergy.cuix")

                Application.SetSystemVariable("FILEDIA", iFILEDIA)
                Application.SetSystemVariable("CMDECHO", iCMDECHO)


            End If


            Select Case _sIdleHandlerOwner
                Case "AcadBeginDoubleClick"
                    Try
                        _bTitleBlockDoubleClicked = False
                        Dim frm As New frmTitleBlockEditor
                        Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(frm)

                    Catch ex As Autodesk.AutoCAD.Runtime.Exception
                        MsgBox(ex.Message.ToString)

                    End Try

                Case Else

            End Select

            _sIdleHandlerOwner = ""
            RemoveHandler Application.Idle, AddressOf AcadIdle



        End Sub

        'Private Sub AcadSelectionAdded(ByVal sender As Object, ByVal e As SelectionAddedEventArgs)

        'End Sub 'AcadSelectionAdded

        Sub AcadDocumentLockModeChanged(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DocumentLockModeChangedEventArgs)

            'Begin Sub
            '=========
            'Set global DocumentLockMode variable
            _eDocumentLockMode = e.CurrentMode

            Debug.Print(e.GlobalCommandName.ToString)

            Select Case e.GlobalCommandName.ToString
                Case "BEDIT", "EATTEDIT", "CUILOAD"
                    If _sIdleHandlerOwner = "AcadBeginDoubleClick" Then
                        'Cancel command, turn on idle event handler, and reset flag
                        e.Veto()
                        AddHandler Application.Idle, AddressOf AcadIdle
                    End If

                Case Else
                    Debug.Print(e.GlobalCommandName.ToString)
            End Select




        End Sub

        Private Sub AcadDWG_CommandEnded(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.CommandEventArgs) Handles AcadDWG.CommandEnded

            Debug.Print("CommandEnded")

        End Sub

        Sub AcadEndDwgOpen(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DrawingOpenEventArgs)

            'Dim oDwg As Document = Application.DocumentManager.MdiActiveDocument

            ''Make sure FirstEnergy CUIx file is loaded
            'If Not modAcadUI.IsPartialCuiFileLoaded("FirstEnergy") Then
            '   Call modAcadUI.LoadPartialCuiFile(oDwg, g_sSupportFilePath &amp;amp; "\FirstEnergy.cuix")
            'End If


        End Sub

        Sub AcadDocumentActivated(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DocumentCollectionEventArgs)

            'Dim oDwg As Document = Application.DocumentManager.MdiActiveDocument

            ''Turn on AppIdle event when FirstEnergy CUIx file is not loaded
            'If Not modAcadUI.IsPartialCuiFileLoaded("FirstEnergy") Then
            '   AddHandler Application.Idle, AddressOf AcadIdle
            'End If

        End Sub




    End Class

End Namespace&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 30 Nov 2013 02:24:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-11-30T02:24:56Z</dc:date>
    <item>
      <title>Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4650733#M46773</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying to find help on replacing Mtext in a drawing border of mine. The drawing border is a block that has constant attributes that I have a vb.net dll that can edit the constant attributes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to add this to that dll, I would like this to work in such a way as to not have the user involved. My thought was to have the code executed when the form was loaded to edit the values in the titleblock. The code would look to see if the Mtext existed in the border and if so replace it with the correct Mtext. If the correct Mtext is there it would exit the Sub.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm have a hard time figuring out how to use the Transaction concept. I've tried to modify an exisitng function in the VB.net dll to do this change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see in this example code, I'm not very good at figuring out how to modify it to my needs. I'm still not sure how some of these "BIG PICTURE" concepts work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I need one function to read and another function to write? Do I need a Sub to strat to function(s)?&amp;nbsp; I understand most of &amp;nbsp;form code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers in the correct direction would be appreciated....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Public&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Shared&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Function&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; ReadMtextFromBTR(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;ByVal&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; strName &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;MText&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;MText&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; MtxtList &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;List&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Of&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; Text.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;StringBuilder&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oDwg &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;Document&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = Autodesk.AutoCAD.ApplicationServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;Application&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.DocumentManager.MdiActiveDocument&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oDB &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;Database&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;= oDwg.Database&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oTransMgr &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;TransactionManager&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;= oDB.TransactionManager&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oTrans &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;Transaction&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;= oTransMgr.StartTransaction&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Using&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;oTrans&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oDatabaseObject &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;DBObject&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = oDB.BlockTableId.GetObject(DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;OpenMode&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.ForRead)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oBlockTable &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTable&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;DirectCast&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;(oDatabaseObject, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTable&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oBTRE &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;SymbolTableEnumerator&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;= oBlockTable.GetEnumerator&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;While&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;oBTRE.MoveNext&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oDBObject &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;DBObject&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = oBTRE.Current.GetObject(DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;OpenMode&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.ForRead)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oBTR &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTableRecord&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;DirectCast&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;(oDBObject, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTableRecord&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oBTR.Name = strName.Text &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;For&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Each&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oObjectID &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;ObjectId&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;In&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;oBTR&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oEnt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;DBObject&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = oTrans.GetObject(oObjectID, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;OpenMode&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.ForRead)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;'If oEnt.GetType.ToString = "Autodesk.AutoCAD.DatabaseServices.AttributeDefinition" Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;TypeOf&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oEnt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Is&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; Autodesk.AutoCAD.DatabaseServices.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;MText&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;oEnt.UpgradeOpen()&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; oEnt.ToString &amp;gt;= (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"FirstEnergy "&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Case&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Case&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"FirstEnergy GENERATION CORP."&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Return&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;strName&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Case&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"FirstEnergy _"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;GENERATION, LLC"&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Return&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Case Else&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Throw&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;Exception&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"The border did not match any of the defined types."&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Next&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;While&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;'oTrans.Commit()&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Using&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;oTrans.Dispose()&lt;/P&gt;&lt;P&gt;oTransMgr.Dispose()&lt;/P&gt;&lt;P&gt;oDB.Dispose()&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Return&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; MtxtList&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2013 19:42:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4650733#M46773</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-25T19:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4651313#M46774</link>
      <description>&lt;P&gt;So your main question is how to better understand how to better understand and use the .NET API? If so, I recommend you work through the .NET Training Labs we have posted here - &lt;A href="http://www.autodesk.com/developautocad" target="_blank"&gt;www.autodesk.com/developautocad&lt;/A&gt; (under the 'Learning' section. Note that there is also a 'DevTV' link to the left of the links to the material that includes a set of videos talking therough each of the training labs. If you're very new to programming, then the 'My First Plug-in' tutorial on the same page may be helpful too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW In your code below, you seem to have commented out the 'trans.Commit()' line, which means your transaction will be aborted when it is Disposed and any changes you made to the drawing since you started the transaction will be rolled back. You should also look in the tutorials I mention how you can use For Each...Next instead of GetEnumerator/MoveNext - its a lot simpler.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 00:49:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4651313#M46774</guid>
      <dc:creator>StephenPreston</dc:creator>
      <dc:date>2013-11-26T00:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4652461#M46775</link>
      <description>&lt;P&gt;To get all the mtext in a block, you can use selection filter. Selection filter will accumulate all entity according to your selection. Below I have create a code snip which will gather all the mtext in the model space. Please see below.&lt;/P&gt;&lt;PRE&gt; Public Shared Function GetMTextBTR(acEd As Editor) As ObjectIdCollection
        Dim tvs(0) As TypedValue
        tvs.SetValue(New TypedValue(DxfCode.Start, "MTEXT"), 0)
        Dim sf As New SelectionFilter(tvs)
        Dim psr As PromptSelectionResult = acEd.SelectAll(sf)
        If psr.Status = PromptStatus.OK Then
            Return New ObjectIdCollection(psr.Value.GetObjectIds())
        Else
            Return New ObjectIdCollection()
        End If
    End Function
    &amp;lt;CommandMethod("tst")&amp;gt; Public Sub TESTMtext()
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor
        Using tx As Transaction = db.TransactionManager.StartTransaction()
            Dim bt As BlockTable = tx.GetObject(db.BlockTableId, OpenMode.ForRead)
            Dim ms As BlockTableRecord = tx.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
            Dim objIdColl As ObjectIdCollection = GetMTextBTR(ed)
            For Each objId As ObjectId In objIdColl
                'DO SOMETHING
            Next
            tx.Commit()
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 11:06:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4652461#M46775</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T11:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4652887#M46776</link>
      <description>&lt;P&gt;mzakiralam&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the Code snippet.&lt;/P&gt;&lt;P&gt;In your example code, I don't have a grasp on what I should be placing for code in the "DO Something" area.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to use a "If statement" to determine if the particular Mtext is what I want to change. I can't seem to unerstand how to do this part. (see below)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "Lightbulb" is starting to glow &lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://forums.autodesk.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt; I see the function piece in the command sub.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason your supplied code wasn't liked "as is". I had to change it to this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Using&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; tx &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;Transaction&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;= db.TransactionManager.StartTransaction()&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; bt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTable&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;CType&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;(tx.GetObject(db.BlockTableId, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;OpenMode&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.ForRead), &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTable&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; ms &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTableRecord&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;CType&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;(tx.GetObject(bt(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTableRecord&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.ModelSpace), &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;OpenMode&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.ForRead), &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;BlockTableRecord&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; objIdColl &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;ObjectIdCollection&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = FirstEnergy.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;AutoCADFunctions&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.GetMTextBTR(ed)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;For&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Each&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; objId &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;&lt;FONT size="2" color="#2b91af" face="Consolas"&gt;ObjectId&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;In&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; objIdColl &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;&lt;FONT size="2" color="#008000" face="Consolas"&gt;'DO SOMETHING Next &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; objId.GetObject(ms.Equals(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"TEST"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;) Then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;MsgBox(&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"you found it"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Else&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;MsgBox(&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"that's not it"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;Next&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 14:23:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4652887#M46776</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T14:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4652991#M46777</link>
      <description>&lt;P&gt;I was not sure what you need to do. This is why after&amp;nbsp; getting the objectId , I have written "Do Something" &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;. Is it now working for you?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if not please see my below code and further explanation. Suppose I have created three MTEXT in my drawing and MTEXT are test1, test2 and test3. If test1&amp;nbsp;is found it will give a message like "found test1" and so on for others. Please see below code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; &amp;lt;CommandMethod("tst")&amp;gt; Public Sub TESTMtext()
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor
        Using tx As Transaction = db.TransactionManager.StartTransaction()
            Dim bt As BlockTable = tx.GetObject(db.BlockTableId, OpenMode.ForRead)
            Dim ms As BlockTableRecord = tx.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
            Dim objIdColl As ObjectIdCollection = GetMTextBTR(ed)
            For Each objId As ObjectId In objIdColl
                'get the Mtext from objectID
                Dim mtxt As MText = tx.GetObject(objId, OpenMode.ForWrite)
                'check mtext content
                If mtxt.Contents = "test1" Then
                    MsgBox("found test1")
                ElseIf mtxt.Contents = "test2" Then
                    MsgBox("found test2")
                ElseIf mtxt.Contents = "test3" Then
                    MsgBox("found test3")
                End If
            Next
            tx.Commit()
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 15:06:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4652991#M46777</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T15:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653121#M46778</link>
      <description>&lt;P&gt;No,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still gropeing along trying to figure out what to plug into the&amp;nbsp;"Do Something". I kinda understand the Function you supplied. It is collecting object Ids that are Mtext and adding them to the editor? Or is the Function looking for something specifically called "MTEXT"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is Find this Mtext ("FirstEnergy GENERATION CORP.") and replace with ("FirstEnergy GENERATION, LLC).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is only one (1) of these Mtext strings in the block reference.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 15:26:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653121#M46778</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T15:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653171#M46779</link>
      <description>&lt;P&gt;My function will collect all MText entities in the model space. It is not related with something Special. It will only collect objectId which DBObject are MText. After getting objectId, you can get MText . Then you can implement your purpose . According to your Need I have modified above code. Please see below. I did not try this code. But it should work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;CommandMethod("tst")&amp;gt; Public Sub TESTMtext()
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor
        Using tx As Transaction = db.TransactionManager.StartTransaction()
            Dim bt As BlockTable = tx.GetObject(db.BlockTableId, OpenMode.ForRead)
            Dim ms As BlockTableRecord = tx.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
            Dim objIdColl As ObjectIdCollection = GetMTextBTR(ed)
            For Each objId As ObjectId In objIdColl
                'get the Mtext from objectID
                Dim mtxt As MText = tx.GetObject(objId, OpenMode.ForWrite)
                'check mtext content
                If mtxt.Contents = "FirstEnergy GENERATION CORP." Then
                   mtxt.contents = "FirstEnergy GENERATION, LLC"
                End If
            Next
            tx.Commit()
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 15:39:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653171#M46779</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T15:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653207#M46780</link>
      <description>&lt;P&gt;OK!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bulb getting a little brighter &lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://forums.autodesk.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt; So I should be able to find said string, then replace it with new string&amp;nbsp;and commit?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SO, if I figure out the FIND replace I can call this "Command" when the FORM loads? It will automatically search and replace if necessary?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 15:43:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653207#M46780</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T15:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653209#M46781</link>
      <description>To understand properly of that function, you can have a look in below link.&lt;BR /&gt;&lt;BR /&gt;&lt;A target="_blank" href="http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff2566ffd511ff6f8c7ca-4067.htm"&gt;http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff2566ffd511ff6f8c7ca-4067.htm&lt;/A&gt;</description>
      <pubDate>Tue, 26 Nov 2013 15:43:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653209#M46781</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T15:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653217#M46782</link>
      <description>In that case you do not Need to call this command. Just put that Sub routine in the form loading Event.</description>
      <pubDate>Tue, 26 Nov 2013 15:44:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653217#M46782</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T15:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653843#M46783</link>
      <description>&lt;P&gt;Well, still stumbling.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to shorten what Mtext to look for (see code) but nothing is happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed in the code you've supplied that there isn't anything that is qualifying the MText to look for, like inside a Blockreference? Does the function care? Can it see Mtext in the Block reference?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I did a properties on an example Mtext = " CORP." and the properties show a bunch of formating info. Is the formating info ignored when the Function/ Sub&amp;nbsp;is executed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        Public Sub TESTMtext()

            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor



            Using tx As Transaction = db.TransactionManager.StartTransaction()

                Dim bt As BlockTable = tx.GetObject(db.BlockTableId, OpenMode.ForRead)
                Dim ms As BlockTableRecord = tx.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
                Dim objIdColl As ObjectIdCollection = FirstEnergy.AutoCADFunctions.GetMTextBTR(ed)

                For Each objId As ObjectId In objIdColl
                    'get the Mtext from objectID
                    Dim mtxt As MText = tx.GetObject(objId, OpenMode.ForWrite)
                    'check mtext content
                    If mtxt.Contents = (" CORP.") Then
                        mtxt.Contents = (", LLC")
                    End If
                Next


                tx.Commit()
            End Using&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 17:20:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4653843#M46783</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T17:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654019#M46784</link>
      <description>with this current function , it will not look MText in any BlockReference. I will try to accumulate objectId of MText if it is in ModelSpace. If your MText are in a block reference then enter into that block reference and apply that function.</description>
      <pubDate>Tue, 26 Nov 2013 18:21:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654019#M46784</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T18:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654113#M46785</link>
      <description>&lt;P&gt;I really do not know how you could use that function for your purposes or&amp;nbsp;use Editor.SelectAll on&amp;nbsp; BlockTableRecord without a layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a thread where Norman helps someone and&amp;nbsp;shows how to use a selection filter to get all&amp;nbsp;BlockReferences then look inside the blocks.&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="https://forums.autodesk.com/t5/NET/Blocks-attributes-and-selection-sets/m-p/4331537/highlight/true"&gt;http://forums.autodesk.com/t5/NET/Blocks-attributes-and-selection-sets/m-p/4331537/highlight/true&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are much better ways to streamline this and make it reusable, but just for learning purposes here is another approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;At the top is a string which would be the name of the block.&lt;/LI&gt;&lt;LI&gt;Both methods check to see if the drawing contains the block.&lt;/LI&gt;&lt;LI&gt;Instead of opening every object to check if it is the correct type there is a property you can check from the ObjectId to save time.&lt;/LI&gt;&lt;LI&gt;Since you mention constant attributes those will be contained in the BlockTableRecord only and not attached to the BlockReferences&lt;/LI&gt;&lt;LI&gt;Mtext.Text returns a string with formatting removed &amp;amp; Mtext.Contents will contain formatting&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;So making part of mtext bold and and changing the last bit to red the attached drawing will print&lt;/P&gt;&lt;P&gt;Mtext.Contents = THIS IS {\fArial|b1|i0|c0|p34;MTEXT \C1;FORMATTED}&lt;BR /&gt;Mtext.Text= THIS IS MTEXT FORMATTED&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have not written VB for a long time, Sorry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   Dim blockName As String = "BlockName"
        &amp;lt;CommandMethod("LooKForMtext")&amp;gt; _
        Public Sub LooKForMtext() 
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            Using trx As Transaction = db.TransactionManager.StartTransaction()

                Dim blockTbl As BlockTable = trx.GetObject(db.BlockTableId, OpenMode.ForRead)

                If Not blockTbl.Has(blockName) Then
                    ed.WriteMessage(Environment.NewLine &amp;amp; "Block not in drawing")
                    Return
                End If

                Dim block As BlockTableRecord = trx.GetObject(blockTbl(blockName), OpenMode.ForRead)

                Dim mtxtClassptr As IntPtr = RXClass.GetClass(GetType(MText)).UnmanagedObject

                For Each entId As ObjectId In block
                    If entId.ObjectClass.UnmanagedObject = mtxtClassptr Then
                        Dim mtxt As MText = trx.GetObject(entId, OpenMode.ForRead)
                        ed.WriteMessage(Environment.NewLine &amp;amp; mtxt.Contents)
                        ed.WriteMessage(Environment.NewLine &amp;amp; mtxt.Text)
                    End If
                Next

            End Using

        End Sub

        &amp;lt;CommandMethod("LooKForConstantAttributes")&amp;gt; _
        Public Sub LooKForConstantAttributes() ' This method can have any name
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            Using trx As Transaction = db.TransactionManager.StartTransaction()

                Dim blockTbl As BlockTable = trx.GetObject(db.BlockTableId, OpenMode.ForRead)

                If Not blockTbl.Has(blockName) Then
                    ed.WriteMessage(Environment.NewLine &amp;amp; "Block not in drawing")
                    Return
                End If

                Dim block As BlockTableRecord = trx.GetObject(blockTbl(blockName), OpenMode.ForRead)

                If Not block.HasAttributeDefinitions Then
                    ed.WriteMessage(Environment.NewLine &amp;amp; "No attributes in block")
                    Return
                End If


                Dim attDefClassptr As IntPtr = RXClass.GetClass(GetType(AttributeDefinition)).UnmanagedObject

                For Each entId As ObjectId In block
                    If entId.ObjectClass.UnmanagedObject = attDefClassptr Then
                        Dim attDef As AttributeDefinition = trx.GetObject(entId, OpenMode.ForRead)
                        ed.WriteMessage(Environment.NewLine &amp;amp; attDef.Constant)
                        ed.WriteMessage(Environment.NewLine &amp;amp; attDef.Tag)
                        If attDef.IsMTextAttributeDefinition Then
                            ed.WriteMessage(Environment.NewLine &amp;amp; attDef.MTextAttributeDefinition.Contents)
                        Else
                            ed.WriteMessage(Environment.NewLine &amp;amp; attDef.TextString)
                        End If

                    End If

                Next

            End Using

        End Sub



    End Class&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 19:15:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654113#M46785</guid>
      <dc:creator>jeff</dc:creator>
      <dc:date>2013-11-26T19:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654181#M46786</link>
      <description>&lt;P&gt;Forgot to commit transaction and should not hard code values inside fuction but this will get you started&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        &amp;lt;CommandMethod("LooKForMtext")&amp;gt; _
        Public Sub LooKForMtext() ' This method can have any name
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            Using trx As Transaction = doc.TransactionManager.StartTransaction()

                Dim blockTbl As BlockTable = trx.GetObject(db.BlockTableId, OpenMode.ForRead)

                If Not blockTbl.Has(blockName) Then
                    ed.WriteMessage(Environment.NewLine &amp;amp; "Block not in drawing")
                    Return
                End If

                Dim block As BlockTableRecord = trx.GetObject(blockTbl(blockName), OpenMode.ForRead)

                Dim mtxtClassptr As IntPtr = RXClass.GetClass(GetType(MText)).UnmanagedObject

                For Each entId As ObjectId In block
                    If entId.ObjectClass.UnmanagedObject = mtxtClassptr Then
                        Dim mtxt As MText = trx.GetObject(entId, OpenMode.ForRead)
                        If mtxt.Text.IndexOf("FirstEnergy GENERATION CORP", StringComparison.InvariantCultureIgnoreCase) &amp;gt;= 0 Then
                            mtxt.UpgradeOpen()
                            mtxt.Contents = mtxt.Contents.Replace("CORP", "LLC")
                        End If
                    End If
                Next
                trx.Commit()
            End Using
            ed.Regen()
        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 19:54:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654181#M46786</guid>
      <dc:creator>jeff</dc:creator>
      <dc:date>2013-11-26T19:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654201#M46787</link>
      <description>&lt;P&gt;Thank you!!!! Jeff,&lt;/P&gt;&lt;DIV class="username_area"&gt;mzakiralam, &amp;amp; Stephen&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've learned more in the past few hours than all the rest of the time I've&lt;BR /&gt;tried to figure this out on my own, on my own I've spent weeks looking at&lt;BR /&gt;example code.&lt;BR /&gt;The code sorta made sense, but the context is what I believe was&lt;BR /&gt;missing. Not knowing how to apply it is very frustrating.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 20:10:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654201#M46787</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T20:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654415#M46788</link>
      <description>&lt;P&gt;Please mark Jeff's answer as an Accepted Solution (and give him Kudos) if his code answered your question :-).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 21:55:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654415#M46788</guid>
      <dc:creator>StephenPreston</dc:creator>
      <dc:date>2013-11-26T21:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654663#M46789</link>
      <description>&lt;P&gt;I'm still struggling,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't seem to grab the Block "that is there" to look for the Mtext.&amp;nbsp;Tried to dim the&amp;nbsp;TypedValue as a block but doesn't seem to effect the&amp;nbsp;code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Aslo tried the&lt;/P&gt;&lt;P&gt;Dim&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;blockname &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;As &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;&lt;FONT size="2" color="#0000ff" face="Consolas"&gt;String&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt; = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;"F-size" &lt;FONT face="arial black,avant garde"&gt;&amp;lt;---this is one of the Blocks that could be in the drawing.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#a31515" face="arial black,avant garde"&gt;&lt;FONT size="2" color="#a31515"&gt;&lt;FONT size="2" color="#a31515"&gt;It always says the block isn't there?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;&lt;FONT size="2" color="#a31515" face="Consolas"&gt;I don't understand what I'm missing?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2013 02:36:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654663#M46789</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-27T02:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654997#M46790</link>
      <description>&lt;P&gt;Can you send your drawing? I am sorry that yesterday , I did not understand your requirement fully.Therefore I only mention about MText in the model space block. Do you want to change some text which is as the attribute of a block reference in the drawing?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2013 09:05:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4654997#M46790</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-27T09:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4656929#M46791</link>
      <description>&lt;DIV class="author-role-icon"&gt;&lt;DIV class="lia-message-author-username lia-component-user-name"&gt;&lt;DIV class="username_area"&gt;&amp;nbsp;&lt;DIV class="username_area"&gt;mzakiralam,&lt;/DIV&gt;&lt;DIV class="username_area"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="username_area"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="username_area"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="username_area"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="username_area"&gt;&lt;BR /&gt;&lt;BR /&gt;I'm not trying to replace Mtext in an attribute, the Mtext&amp;nbsp;is&amp;nbsp;just inside the "titleblock" BLOCK. I've attached one of the template files that has the Mtext I'm trying to replace.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 27 Nov 2013 20:44:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4656929#M46791</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-27T20:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Finding &amp; Replacing Mtext in a Block using VB.net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4656955#M46792</link>
      <description>Did you attach the file? I can not see any attachment.</description>
      <pubDate>Wed, 27 Nov 2013 20:48:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/finding-amp-replacing-mtext-in-a-block-using-vb-net/m-p/4656955#M46792</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-27T20:48:13Z</dc:date>
    </item>
  </channel>
</rss>

