<?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: Select All in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553246#M54331</link>
    <description>&lt;P&gt;But if i replace TextString by Origins or Points can i get the Starting location/Mid Point of Texts. So that i will write another logic by specifying Points and search in range to get texts&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jul 2012 07:07:20 GMT</pubDate>
    <dc:creator>amitnkukanur</dc:creator>
    <dc:date>2012-07-26T07:07:20Z</dc:date>
    <item>
      <title>Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3551324#M54327</link>
      <description>&lt;P&gt;The below code is one part of code which am using now and i got this solutions here only. Now comming to problem: i am trying my best for select all from screen without opening AutoCAD but they are not successful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any one alter this piece of code so that it will select all without opening CAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Amit&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;Public Shared Sub ReadTexts()&lt;BR /&gt;Dim acadver As String = "18" '//AutoCAD Version&lt;BR /&gt;' Set your file name to read data here&lt;BR /&gt;'Dim fname As String = "C:\Test\tags.dwg"&lt;BR /&gt;&amp;nbsp;' Define csv file name variable&lt;BR /&gt;Dim csvname As String = String.Empty&lt;/P&gt;&lt;P&gt;Dim listData As New List(Of Object)&lt;BR /&gt;' Get current culture&lt;BR /&gt;Dim oldCult As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture&lt;BR /&gt;' Create new culture&lt;BR /&gt;Dim thisCult As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US")&lt;BR /&gt;' Set current culture to newly created&lt;BR /&gt;System.Threading.Thread.CurrentThread.CurrentCulture = thisCult&lt;/P&gt;&lt;P&gt;MsgBox("Wait...")&lt;BR /&gt;Dim appProgID As String = "Autocad.Application" + "." + acadver&lt;/P&gt;&lt;P&gt;' Get reference on interface IDispatch&lt;BR /&gt;Dim AcadType As Type = Type.GetTypeFromProgID(appProgID)&lt;/P&gt;&lt;P&gt;' Run AutoCAD&lt;BR /&gt;Dim AcadApp As Object = Activator.CreateInstance(AcadType)&lt;/P&gt;&lt;P&gt;Dim visargs() As Object = New Object(0) {}&lt;/P&gt;&lt;P&gt;' Set visibility mode to true&lt;BR /&gt;visargs(0) = False&lt;/P&gt;&lt;P&gt;' Make application visible&lt;BR /&gt;AcadApp.GetType().InvokeMember("Visible", BindingFlags.SetProperty, Nothing, AcadApp, visargs, Nothing)&lt;BR /&gt;' Maximize window&lt;BR /&gt;AcadApp.GetType().InvokeMember("WindowState", BindingFlags.SetProperty, Nothing, AcadApp, New Object() {1}, Nothing)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim AcadDocs As Object = AcadApp.GetType().InvokeMember("Documents", BindingFlags.GetProperty, Nothing, AcadApp, Nothing)&lt;/P&gt;&lt;P&gt;' Define arguments to open file&lt;BR /&gt;Dim args() As Object = New Object(1) {}&lt;/P&gt;&lt;P&gt;args(0) = fname&lt;BR /&gt;' Set read only mode to true&lt;BR /&gt;args(1) = False&lt;BR /&gt;' Try open document&lt;BR /&gt;Dim AcDoc As Object = AcadDocs.GetType.InvokeMember("Open", BindingFlags.InvokeMethod, Nothing, AcadDocs, args, Nothing)&lt;/P&gt;&lt;P&gt;Dim AcUtil As Object = New Object&lt;BR /&gt;Try&lt;BR /&gt;' get reference on active document&lt;BR /&gt;AcDoc = AcadApp.GetType.InvokeMember("ActiveDocument", BindingFlags.GetProperty, Nothing, AcadApp, Nothing, Nothing)&lt;BR /&gt;' Get reference on ModelSpace&lt;BR /&gt;Dim AcSpace As Object = AcDoc.GetType.InvokeMember("ModelSpace", BindingFlags.GetProperty, Nothing, AcDoc, Nothing)&lt;BR /&gt;' get reference on Utility&lt;BR /&gt;AcUtil = AcDoc.GetType.InvokeMember("Utility", BindingFlags.GetProperty, Nothing, AcDoc, Nothing, Nothing)&lt;BR /&gt;' get reference on SelectionSets&lt;BR /&gt;Dim AcSsets As Object = AcDoc.GetType.InvokeMember("SelectionSets", BindingFlags.GetProperty, Nothing, AcDoc, Nothing, Nothing)&lt;BR /&gt;' Perform zooming&lt;BR /&gt;AcadApp.GetType.InvokeMember("ZoomExtents", BindingFlags.InvokeMethod, Nothing, AcadApp, Nothing, Nothing)&lt;BR /&gt;' Perform zooming&lt;BR /&gt;AcadApp.GetType.InvokeMember("ZoomScaled", BindingFlags.InvokeMethod, Nothing, AcadApp, New Object() {0.8, 1})&lt;BR /&gt;' Add prompt to the command line&lt;BR /&gt;'AcUtil.GetType.InvokeMember("Prompt", BindingFlags.InvokeMethod, Nothing, AcUtil, New Object() {vbLf &amp;amp; " &amp;gt;&amp;gt; SELECT TEXTS ON SCREEN &amp;gt;&amp;gt; "})&lt;BR /&gt;' Add SelectionSet, named "$SelectionTest$"&lt;BR /&gt;AcSsets.GetType.InvokeMember("Add", BindingFlags.InvokeMethod, Nothing, AcSsets, New Object() {"$SelectionTest$"})&lt;BR /&gt;' Get reference on newly created Selection Set&lt;BR /&gt;Dim AcSset As Object = AcSsets.GetType.InvokeMember("Item", BindingFlags.InvokeMethod Or BindingFlags.GetProperty, Nothing, AcSsets, New Object() {"$SelectionTest$"})&lt;/P&gt;&lt;P&gt;' Create filter to use attributed blocks&lt;BR /&gt;Dim selargs As Object() = New Object(1) {}&lt;/P&gt;&lt;P&gt;Dim ftype As Short() = New Short() {0}&lt;/P&gt;&lt;P&gt;Dim fdata As Object() = New Object() {"*TEXT"}&lt;/P&gt;&lt;P&gt;selargs(0) = DirectCast(ftype, Object)&lt;/P&gt;&lt;P&gt;selargs(1) = DirectCast(fdata, Object)&lt;/P&gt;&lt;P&gt;' Perform selection on screen&lt;/P&gt;&lt;P&gt;'AcSset.GetType.InvokeMember("SelectOnScreen", BindingFlags.InvokeMethod, Nothing, AcSset, selargs)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' Get number of selected items&lt;BR /&gt;Dim cnt As Integer = CInt(AcSset.GetType.InvokeMember("Count", BindingFlags.GetProperty, Nothing, AcSset, Nothing))&lt;BR /&gt;' Add prompt to the command line&lt;BR /&gt;AcUtil.GetType.InvokeMember("Prompt", BindingFlags.InvokeMethod, Nothing, AcUtil, New Object() {vbLf &amp;amp; "--&amp;gt; Selected Mtexts --&amp;gt;" &amp;amp; vbTab &amp;amp; cnt.ToString()})&lt;/P&gt;&lt;P&gt;' Loop through selected objects&lt;BR /&gt;For n As Integer = 0 To cnt - 1&lt;BR /&gt;' Get single item from selection&lt;BR /&gt;Dim AcSelItem As Object = AcSset.GetType.InvokeMember("Item", BindingFlags.InvokeMethod, Nothing, AcSset, New Object() {n})&lt;BR /&gt;' Get Object name&lt;BR /&gt;Dim objName As String = AcSelItem.GetType.InvokeMember("ObjectName", BindingFlags.GetProperty, Nothing, AcSelItem, Nothing).ToString()&lt;BR /&gt;Dim textStr As String = String.Empty&lt;/P&gt;&lt;P&gt;If objName = "AcDbText" Then&lt;BR /&gt;textStr = AcSelItem.GetType.InvokeMember("TextString", BindingFlags.GetProperty, Nothing, AcSelItem, Nothing).ToString()&lt;BR /&gt;ElseIf objName = "AcDbMText" Then&lt;BR /&gt;textStr = AcSelItem.GetType.InvokeMember("TextString", BindingFlags.GetProperty, Nothing, AcSelItem, Nothing).ToString()&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;listData.Add(textStr)&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;Dim initDir As String = AcDoc.GetType.InvokeMember("Path", BindingFlags.GetProperty, Nothing, AcDoc, Nothing, Nothing).ToString()&lt;/P&gt;&lt;P&gt;Dim saveFileDialog As New System.Windows.Forms.SaveFileDialog&lt;/P&gt;&lt;P&gt;saveFileDialog.Title = "Enter a file name to write data: "&lt;/P&gt;&lt;P&gt;saveFileDialog.InitialDirectory = initDir&lt;/P&gt;&lt;P&gt;saveFileDialog.RestoreDirectory = True&lt;/P&gt;&lt;P&gt;saveFileDialog.Filter = "CSV files | *.csv"&lt;/P&gt;&lt;P&gt;saveFileDialog.FileName = "File name without extension"&lt;/P&gt;&lt;P&gt;Dim result As System.Windows.Forms.DialogResult = saveFileDialog.ShowDialog()&lt;/P&gt;&lt;P&gt;If result &amp;lt;&amp;gt; DialogResult.OK Then&lt;BR /&gt;csvname = "Not saved"&lt;BR /&gt;Return&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;csvname = saveFileDialog.FileName&lt;BR /&gt;' Write data&lt;BR /&gt;Using sw As New StreamWriter(csvname, True, Encoding.ASCII)&lt;/P&gt;&lt;P&gt;For Each strline As String In listData&lt;BR /&gt;sw.WriteLine(strline)&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;sw.Flush()&lt;/P&gt;&lt;P&gt;sw.Close()&lt;/P&gt;&lt;P&gt;End Using&lt;/P&gt;&lt;P&gt;'Save document&lt;BR /&gt;Dim closeargs() As Object = New Object(1) {}&lt;BR /&gt;closeargs(0) = True&lt;BR /&gt;' with the same name&lt;BR /&gt;closeargs(1) = fname&lt;BR /&gt;' Try close document&lt;BR /&gt;' Simplified syntax&lt;BR /&gt;AcDoc.GetType().InvokeMember("Close", BindingFlags.InvokeMethod, Nothing, AcDoc, closeargs)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;' Try quit application&lt;BR /&gt;AcadApp.GetType().InvokeMember("Quit", BindingFlags.InvokeMethod, Nothing, AcadApp, Nothing)&lt;/P&gt;&lt;P&gt;Catch ex As System.Exception&lt;/P&gt;&lt;P&gt;MsgBox("Error: " &amp;amp; ex.Message &amp;amp; vbLf &amp;amp; "Trace: " &amp;amp; ex.StackTrace)&lt;/P&gt;&lt;P&gt;Finally&lt;BR /&gt;' clean up the memory&lt;BR /&gt;'--------------------'&lt;BR /&gt;' release Utility.&lt;BR /&gt;releaseObject(AcUtil)&lt;BR /&gt;' release Document.&lt;BR /&gt;releaseObject(AcDoc)&lt;BR /&gt;' release Documents.&lt;BR /&gt;releaseObject(AcadDocs)&lt;BR /&gt;' release Application.&lt;BR /&gt;releaseObject(AcadApp)&lt;BR /&gt;' call garbage cleaner immediatelly&lt;BR /&gt;GC.WaitForPendingFinalizers()&lt;BR /&gt;GC.GetTotalMemory(True)&lt;BR /&gt;GC.WaitForPendingFinalizers()&lt;BR /&gt;GC.GetTotalMemory(True)&lt;BR /&gt;' restore current culture&lt;BR /&gt;System.Threading.Thread.CurrentThread.CurrentUICulture = oldCult&lt;BR /&gt;'Display result&lt;BR /&gt;MsgBox("Csv file saved as : " + csvname)&lt;BR /&gt;End Try&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2012 08:35:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3551324#M54327</guid>
      <dc:creator>amitnkukanur</dc:creator>
      <dc:date>2012-07-25T08:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3552718#M54328</link>
      <description>&lt;P&gt;Try another one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    Public Shared Sub ReadTextFromModel()
        Dim acadver As String = "18" '//AutoCAD Version
        ' Set your file name to read data here
        Dim fname As String = "C:\Test\tags.dwg"
        ' Define csv file name variable
        Dim csvname As String = String.Empty

        Dim listData As New List(Of Object)
        ' Get current culture
        Dim oldCult As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
        ' Create new culture
        Dim thisCult As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US")
        ' Set current culture to newly created
        System.Threading.Thread.CurrentThread.CurrentCulture = thisCult

        MsgBox("Wait...")
        Dim appProgID As String = "Autocad.Application" + "." + acadver

        ' Get reference on interface IDispatch
        Dim AcadType As Type = Type.GetTypeFromProgID(appProgID)

        ' Run AutoCAD
        Dim AcadApp As Object = Activator.CreateInstance(AcadType)

        Dim visargs() As Object = New Object(0) {}

        ' Set visibility mode to false
        visargs(0) = False

        ' Make application visible
        AcadApp.GetType().InvokeMember("Visible", BindingFlags.SetProperty, Nothing, AcadApp, visargs, Nothing)
        ' Maximize window
        ''AcadApp.GetType().InvokeMember("WindowState", BindingFlags.SetProperty, Nothing, AcadApp, New Object() {1}, Nothing)


        Dim AcadDocs As Object = AcadApp.GetType().InvokeMember("Documents", BindingFlags.GetProperty, Nothing, AcadApp, Nothing)

        ' Define arguments to open file
        Dim args() As Object = New Object(1) {}

        args(0) = fname
        ' Set read only mode to false
        args(1) = False
        ' Try open document
        Dim AcDoc As Object = AcadDocs.GetType.InvokeMember("Open", BindingFlags.InvokeMethod, Nothing, AcadDocs, args, Nothing)

        Try
            ' get reference on active document
            AcDoc = AcadApp.GetType.InvokeMember("ActiveDocument", BindingFlags.GetProperty, Nothing, AcadApp, Nothing, Nothing)
            ' Get reference on ModelSpace
            Dim AcSpace As Object = AcDoc.GetType.InvokeMember("ModelSpace", BindingFlags.GetProperty, Nothing, AcDoc, Nothing)

            Dim entCount As Integer = Convert.ToInt32(AcSpace.GetType.InvokeMember("Count", BindingFlags.GetProperty, Nothing, AcSpace, Nothing))

            ' Loop through selected objects
            For index As Integer = 0 To entCount - 1

                ' Get single item from selection
                Dim AcEnt As Object = AcSpace.GetType.InvokeMember("Item", BindingFlags.InvokeMethod, Nothing, AcSpace, New Object() {index})
                ' Get Object name
                Dim objName As String = AcEnt.GetType.InvokeMember("ObjectName", BindingFlags.GetProperty, Nothing, AcEnt, Nothing).ToString()

                Dim textStr As String = String.Empty

                If objName = "AcDbText" Then
                    textStr = AcEnt.GetType.InvokeMember("TextString", BindingFlags.GetProperty, Nothing, AcEnt, Nothing).ToString()
                ElseIf objName = "AcDbMText" Then
                    textStr = AcEnt.GetType.InvokeMember("TextString", BindingFlags.GetProperty, Nothing, AcEnt, Nothing).ToString()
                End If

                listData.Add(textStr)

            Next

            Dim initDir As String = AcDoc.GetType.InvokeMember("Path", BindingFlags.GetProperty, Nothing, AcDoc, Nothing, Nothing).ToString()

            Dim saveFileDialog As New System.Windows.Forms.SaveFileDialog

            saveFileDialog.Title = "Enter a file name to write data: "

            saveFileDialog.InitialDirectory = initDir

            saveFileDialog.RestoreDirectory = True

            saveFileDialog.Filter = "CSV files | *.csv"

            saveFileDialog.FileName = "File name without extension"

            Dim result As System.Windows.Forms.DialogResult = saveFileDialog.ShowDialog()

            If result &amp;lt;&amp;gt; DialogResult.OK Then
                csvname = "Not saved"
                Return
            End If

            csvname = saveFileDialog.FileName
            ' Write data
            Using sw As New StreamWriter(csvname, True, Encoding.ASCII)

                For Each strline As String In listData
                    sw.WriteLine(strline)
                Next

                sw.Flush()

                sw.Close()

            End Using

            'Save document
            Dim closeargs() As Object = New Object(1) {}
            closeargs(0) = True
            ' with the same name
            closeargs(1) = fname
            ' Try close document
            ' Simplified syntax
            AcDoc.GetType().InvokeMember("Close", BindingFlags.InvokeMethod, Nothing, AcDoc, closeargs)


            ' Try quit application
            AcadApp.GetType().InvokeMember("Quit", BindingFlags.InvokeMethod, Nothing, AcadApp, Nothing)

        Catch ex As System.Exception

            MsgBox("Error: " &amp;amp; ex.Message &amp;amp; vbLf &amp;amp; "Trace: " &amp;amp; ex.StackTrace)

        Finally
            ' clean up the memory
            '--------------------'

            ' release Document.
            releaseObject(AcDoc)
            ' release Documents.
            releaseObject(AcadDocs)
            ' release Application.
            releaseObject(AcadApp)
            ' call garbage cleaner immediatelly
            GC.WaitForPendingFinalizers()
            GC.GetTotalMemory(True)
            GC.WaitForPendingFinalizers()
            GC.GetTotalMemory(True)
            ' restore current culture
            System.Threading.Thread.CurrentThread.CurrentUICulture = oldCult
            'Display result
            MsgBox("Csv file saved as : " + csvname)
        End Try

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2012 20:14:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3552718#M54328</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-07-25T20:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3552954#M54329</link>
      <description>&lt;P&gt;Oooh, why do you need to do all the late-binding if you specifcally want to run the code against Acad version 18 (2010)? Have you debugged line by line? What is it that you cannot just set reference to Acad type library and have strongly typed variables (so that it is easier to debug)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have to use late-binding for a mystical reason, you 'd better just started with early-binding to make sure your logic works (it looked like you are still not very familar with Acad programming), worked out all potential issues, then convert it to late-binding with all that&amp;nbsp;"InvokeMember/InvokeMethod" calls, which you do not get intellisense prompt for&amp;nbsp;and thus is error-prone process.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2012 22:17:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3552954#M54329</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2012-07-25T22:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553216#M54330</link>
      <description>&lt;P&gt;Perfect, Thankyou Hallex It worked really Great.&lt;/P&gt;&lt;P&gt;Thankyou Hallex for Supporting me.&lt;/P&gt;&lt;P&gt;Thankyou&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2012 06:29:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553216#M54330</guid>
      <dc:creator>amitnkukanur</dc:creator>
      <dc:date>2012-07-26T06:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553246#M54331</link>
      <description>&lt;P&gt;But if i replace TextString by Origins or Points can i get the Starting location/Mid Point of Texts. So that i will write another logic by specifying Points and search in range to get texts&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2012 07:07:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553246#M54331</guid>
      <dc:creator>amitnkukanur</dc:creator>
      <dc:date>2012-07-26T07:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553252#M54332</link>
      <description>&lt;P&gt;Glad if you got it to work&lt;/P&gt;&lt;P&gt;Cheers &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2012 07:15:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553252#M54332</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-07-26T07:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553256#M54333</link>
      <description>&lt;P&gt;You wrote:&lt;/P&gt;&lt;P&gt;But if i replace TextString by Origins or Points can i get the Starting location/Mid Point of Texts. So that i will write another logic by specifying Points and search in range to get texts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case you need to&amp;nbsp;calculate a mid point,&lt;/P&gt;&lt;P&gt;based on "GetBoundingBox" method of&lt;/P&gt;&lt;P&gt;the text&lt;/P&gt;&lt;P&gt;I havent have an example of the code and also&lt;/P&gt;&lt;P&gt;I'm busy on today with my own...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2012 07:19:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553256#M54333</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-07-26T07:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553260#M54334</link>
      <description>&lt;P&gt;Ok Hallex i will Work on it using GetBoundingBox method of Texts. Thanks for Reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With Warm Regards&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2012 07:26:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3553260#M54334</guid>
      <dc:creator>amitnkukanur</dc:creator>
      <dc:date>2012-07-26T07:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3554400#M54335</link>
      <description>&lt;P&gt;Try this code, I've found the code written by great TT,&lt;/P&gt;&lt;P&gt;in the midpoint of text bounds this will draw a blue circles&lt;/P&gt;&lt;P&gt;for imagination:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Reflection
Imports System.Globalization
Imports System.Collections&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   ' sample aux
    Public Shared Function DrawCircle(ByVal oBlock As Object, ByVal p() As Double, ByVal rad As Double) As Object

        Dim args() As Object = New Object(1) {}
        args(0) = p
        args(1) = rad
        Dim oCirc As Object = oBlock.GetType.InvokeMember("AddCircle", BindingFlags.InvokeMethod, Nothing, oBlock, args)
        Dim norm() As Double = New Double() {0.0, 0.0, 1.0}
        oCirc.GetType().InvokeMember("Normal", BindingFlags.SetProperty, Nothing, oCirc, New Object() {norm})

        Return oCirc
    End Function
    Public Shared Sub ImportTextFromModel()
        Dim acadver As String = "18" '//AutoCAD Version
        ' Set your file name to read data here
        Dim fname As String = "C:\Test\mtext.dwg"
        ' Define csv file name variable
        Dim csvname As String = String.Empty

        Dim listData As New List(Of Object)
        ' Get current culture
        Dim oldCult As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
        ' Create new culture
        Dim thisCult As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US")
        ' Set current culture to newly created
        System.Threading.Thread.CurrentThread.CurrentCulture = thisCult

        MsgBox("Wait...")
        Dim appProgID As String = "Autocad.Application" + "." + acadver

        ' Get reference on interface IDispatch
        Dim AcadType As Type = Type.GetTypeFromProgID(appProgID)

        ' Run AutoCAD
        Dim AcadApp As Object = Activator.CreateInstance(AcadType)

        Dim visargs() As Object = New Object(0) {}

        ' Set visibility mode to false
        visargs(0) = False

        ' Make application visible
        AcadApp.GetType().InvokeMember("Visible", BindingFlags.SetProperty, Nothing, AcadApp, visargs, Nothing)
        ' Maximize window
        ''AcadApp.GetType().InvokeMember("WindowState", BindingFlags.SetProperty, Nothing, AcadApp, New Object() {1}, Nothing)


        Dim AcadDocs As Object = AcadApp.GetType().InvokeMember("Documents", BindingFlags.GetProperty, Nothing, AcadApp, Nothing)

        ' Define arguments to open file
        Dim args() As Object = New Object(1) {}

        args(0) = fname
        ' Set read only mode to false
        args(1) = False
        ' Try open document
        Dim AcDoc As Object = AcadDocs.GetType.InvokeMember("Open", BindingFlags.InvokeMethod, Nothing, AcadDocs, args, Nothing)

        Try
            ' get reference on active document
            AcDoc = AcadApp.GetType.InvokeMember("ActiveDocument", BindingFlags.GetProperty, Nothing, AcadApp, Nothing, Nothing)
            ' Get reference on ModelSpace
            Dim AcSpace As Object = AcDoc.GetType.InvokeMember("ModelSpace", BindingFlags.GetProperty, Nothing, AcDoc, Nothing)

            Dim entCount As Integer = Convert.ToInt32(AcSpace.GetType.InvokeMember("Count", BindingFlags.GetProperty, Nothing, AcSpace, Nothing))

            ' Loop through selected objects
            For index As Integer = 0 To entCount - 1

                ' Get single item from selection
                Dim AcEnt As Object = AcSpace.GetType.InvokeMember("Item", BindingFlags.InvokeMethod, Nothing, AcSpace, New Object() {index})
                ' Get Object name
                Dim objName As String = AcEnt.GetType.InvokeMember("ObjectName", BindingFlags.GetProperty, Nothing, AcEnt, Nothing).ToString()

                Dim textStr As String = String.Empty

                If objName = "AcDbText" Then

                    textStr = AcEnt.GetType.InvokeMember("TextString", BindingFlags.GetProperty, Nothing, AcEnt, Nothing).ToString()
                    listData.Add(textStr)

                    '_____________________________________________

                    ' written by Tony Tanzillo
                    '_____________________________________________

                    ' The array of arguments that will be passed
                    ' to the AcadEntity.GetBoundingBox() method:
                    Dim boxargs As Object() = New Object(1) {}

                    ' In order to get VT_BYREF | VT_VARIANT arguments to be
                    ' filled in by the callee, we must use VariantWrappers
                    ' as the arguments:

                    ' The callee will replace the VariantWrappers
                    ' in the args[] argument array with the results.

                    boxargs(0) = New VariantWrapper(0)
                    boxargs(1) = New VariantWrapper(0)

                    ' We also need to tell the marshaler that
                    ' both parameters in the COM method call are
                    ' 'out' or 'byref' parameters:

                    ' 2 = the total number of arguments passed:
                    Dim pm As New ParameterModifier(2)

                    pm(0) = True
                    ' first argument is byref
                    pm(1) = True
                    ' second argument is byref
                    Dim modifiers As ParameterModifier() = New ParameterModifier() {pm}

                    ' Invoke the method, passing the arguments, and
                    ' the parameter modifers

                    AcEnt.GetType().InvokeMember("GetBoundingBox", BindingFlags.InvokeMethod, Nothing, AcEnt, boxargs, modifiers, Nothing, Nothing)

                    ' The results are now in the args[] array:

                    Dim ll As Double() = DirectCast(boxargs(0), Double())
                    Dim ur As Double() = DirectCast(boxargs(1), Double())
                    '________________________________________________________


                    'dispay result (debug only)
                    'MessageBox.Show(String.Format("Point is ({0:f3} , {1:f3} , {2:f3})", ll(0), ll(1), ll(2)))
                    'draw circle in the midpont of text bounds
                    Dim midPt() As Double = New Double() {(ll(0) + ur(0)) / 2, (ll(1) + ur(1)) / 2, (ll(2) + ur(2)) / 2}

                    DrawCircle(AcSpace, midPt, 0.5)

                End If

            Next

            Dim initDir As String = AcDoc.GetType.InvokeMember("Path", BindingFlags.GetProperty, Nothing, AcDoc, Nothing, Nothing).ToString()

            Dim saveFileDialog As New System.Windows.Forms.SaveFileDialog

            saveFileDialog.Title = "Enter a file name to write data: "

            saveFileDialog.InitialDirectory = initDir

            saveFileDialog.RestoreDirectory = True

            saveFileDialog.Filter = "CSV files | *.csv"

            saveFileDialog.FileName = "File name without extension"

            Dim result As System.Windows.Forms.DialogResult = saveFileDialog.ShowDialog()

            If result &amp;lt;&amp;gt; DialogResult.OK Then
                csvname = "Not saved"
                Return
            End If

            csvname = saveFileDialog.FileName

            ' Write data to CSV
            Using sw As New StreamWriter(csvname, True, Encoding.ASCII)

                For Each strline As String In listData
                    sw.WriteLine(strline)
                Next

            End Using

            'Save document
            Dim closeargs() As Object = New Object(1) {}
            closeargs(0) = True
            ' with the same name
            closeargs(1) = fname
            ' Try close document
            ' Simplified syntax
            AcDoc.GetType().InvokeMember("Close", BindingFlags.InvokeMethod, Nothing, AcDoc, closeargs)


            ' Try quit application
            AcadApp.GetType().InvokeMember("Quit", BindingFlags.InvokeMethod, Nothing, AcadApp, Nothing)

        Catch ex As System.Exception

            MsgBox("Error: " &amp;amp; ex.Message &amp;amp; vbLf &amp;amp; "Trace: " &amp;amp; ex.StackTrace)

        Finally
            ' Try quit application
            AcadApp.GetType().InvokeMember("Quit", BindingFlags.InvokeMethod, Nothing, AcadApp, Nothing)
            ' clean up the memory
            '--------------------'

            ' release Document.
            releaseObject(AcDoc)
            ' release Documents.
            releaseObject(AcadDocs)
            ' release Application.
            releaseObject(AcadApp)
            ' call garbage cleaner immediatelly
            GC.WaitForPendingFinalizers()
            GC.GetTotalMemory(True)
            GC.WaitForPendingFinalizers()
            GC.GetTotalMemory(True)
            ' restore current culture
            System.Threading.Thread.CurrentThread.CurrentUICulture = oldCult
            'Display result
            MsgBox("Csv file saved as : " + csvname)
        End Try

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008080" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2012 18:15:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3554400#M54335</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-07-26T18:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3554994#M54336</link>
      <description>&lt;P&gt;Perfect, it worked Hallex. Thank you Hallex Thanks a Lot&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2012 04:56:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3554994#M54336</guid>
      <dc:creator>amitnkukanur</dc:creator>
      <dc:date>2012-07-27T04:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select All</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3555000#M54337</link>
      <description>&lt;P&gt;You're welcome,&lt;/P&gt;&lt;P&gt;Cheers &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2012 05:08:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-all/m-p/3555000#M54337</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-07-27T05:08:18Z</dc:date>
    </item>
  </channel>
</rss>

