<?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: Crashing when exporting large amount of points to csv vb.net in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3571328#M54009</link>
    <description>&lt;P&gt;I just imagine how it would be, coz I haven't have Civil3d on my end&lt;/P&gt;&lt;P&gt;See code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    &amp;lt;CommandMethod("exporter")&amp;gt; _
    Public Sub ShowObjectDataInfo()
        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
        Dim oAcadApp As AcadApplication = Application.AcadApplication

        Try
            If oAcadApp Is Nothing Then
                oAcadApp = GetObject(, "AutoCAD.Application")
            End If
        Catch ex As System.Exception
            ed.WriteMessage(ex.Message)
        End Try

        oAeccApp = oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.9.0")
        oAeccDoc = oAeccApp.ActiveDocument
        oAeccDB = oAeccApp.ActiveDocument.Database

        Dim CSV_FileName As String = Nothing

        Try
            ' navigate to the point text csv file using a file dialog
            Dim dlg As New System.Windows.Forms.SaveFileDialog()
            dlg.InitialDirectory = "C:\"
            dlg.RestoreDirectory = True
            dlg.Filter = "csv excel files (*.csv)|*.csv|All files (*.*)|*.*"

            If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then

                CSV_FileName = dlg.FileName().ToString
            End If

            Dim oPoints As Autodesk.AECC.Interop.Land.AeccPoints
            Dim sFilename As String
            Dim iCount As Integer

            oPoints = oAeccDB.Points

            sFilename = CSV_FileName
            Dim builder As New StringBuilder

            Dim desc As String
            Dim pid As Integer
            Dim x, y, z As Double


            For Each oPoint In oAeccDB.Points

                pid = oPoint.Number
                x = oPoint.Easting
                y = oPoint.Northing
                z = oPoint.Elevation
                desc = oPoint.RawDescription

                Dim id As ObjectId = PointEntity.FromAcadObject(oPoint)


                Dim tables As Tables
                tables = HostMapApplicationServices.Application.ActiveProject.ODTables
                Dim records As Records = tables.GetObjectRecords(Convert.ToUInt32(0), id, Constants.OpenMode.OpenForRead, False)



                ' Iterate through all records
                Dim record As Record = records.Item(0)



                For Each record In records
                    Dim msg(12) As String

                    ' Get the table
                    Dim table As ObjectData.Table = tables(record.TableName)


                    Dim str As String = Nothing



                    ' Get record info
                    Dim i As Integer
                    Dim upbound As Integer = record.Count - 1
                    For i = 2 To upbound - 1
                        Dim val As MapValue = record(i)

                        str = val.StrValue
                        msg(i - 1) = str()
                    Next i

                    Dim rec As String = String.Format("{0}" + vbTab + "{1}" + vbTab + "{2}" + vbTab + "{3}" + vbTab + _
                                                      "{4}" + vbTab + "{5}" + vbTab + "{6}" + vbTab + "{7}" + vbTab + _
                                                      "{8}" + vbTab + "{9}" + vbTab + "{10}" + vbTab + "{11}" + vbTab + _
                                                      "{12}" + vbTab + "{13}" + vbTab + "{14}" + vbTab + "{15}",
                                                      pid, y, x, z, desc, msg(1), msg(2), msg(3), msg(4), msg(5), msg(6),
                                                      msg(7), msg(8), msg(9), msg(10), msg(11))
                    builder.AppendLine(rec)

                Next

                Using inWriter As New StreamWriter(sFilename)
                    inWriter.WriteLine(builder.ToString)
                    inWriter.Flush()
                End Using
                GC.Collect()

        Catch ex As System.Exception
            MsgBox(ex.Message + vbLf + ex.StackTrace)
        Finally

        End Try

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&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>Thu, 09 Aug 2012 08:00:36 GMT</pubDate>
    <dc:creator>Hallex</dc:creator>
    <dc:date>2012-08-09T08:00:36Z</dc:date>
    <item>
      <title>Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3569884#M54001</link>
      <description>&lt;P&gt;Trying to export points to a csv with the object data that is attached to the point. I can use this and it works great for smaller projects, but crashes every time when I try to export a larg amount of points. The most it has successfully exported was 9000 points but on average it usually will get to 3000 points before i get a fatal error and everything crashes.&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;Dim CSV_FileName As String = Nothing&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;' navigate to the point text csv file using a file dialog&lt;BR /&gt;Dim dlg As New System.Windows.Forms.SaveFileDialog()&lt;BR /&gt;dlg.InitialDirectory = "C:\"&lt;BR /&gt;dlg.Filter = "csv excel files (*.csv)|*.csv|All files (*.*)|*.*"&lt;/P&gt;&lt;P&gt;If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then&lt;/P&gt;&lt;P&gt;CSV_FileName = dlg.FileName().ToString&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Dim oPoints As Autodesk.AECC.Interop.Land.AeccPoints&lt;BR /&gt;Dim sFilename As String&lt;BR /&gt;'Dim iCount As Integer&lt;/P&gt;&lt;P&gt;oPoints = oAeccDB.Points&lt;BR /&gt;&lt;BR /&gt;sFilename = CSV_FileName&lt;/P&gt;&lt;P&gt;Dim inWriter As New StreamWriter(sFilename)&lt;BR /&gt;Dim pid, desc As String&lt;BR /&gt;Dim x, y, z As Double&lt;/P&gt;&lt;P&gt;Dim oPoint As Autodesk.AECC.Interop.Land.AeccPoint&lt;/P&gt;&lt;P&gt;Dim cnt As Long = oPoints.Count&lt;BR /&gt;Dim expline(cnt) As String&lt;BR /&gt;Dim n As Long&lt;BR /&gt;For n = 0 To cnt - 1&lt;/P&gt;&lt;P&gt;oPoint = oPoints.Item(n)&lt;BR /&gt;pid = oPoint.Number&lt;BR /&gt;x = oPoint.Easting&lt;BR /&gt;y = oPoint.Northing&lt;BR /&gt;z = oPoint.Elevation&lt;BR /&gt;desc = oPoint.RawDescription&lt;/P&gt;&lt;P&gt;Dim id As ObjectId = PointEntity.FromAcadObject(oPoint)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim tables As Tables&lt;BR /&gt;tables = HostMapApplicationServices.Application.ActiveProject.ODTables&lt;BR /&gt;Dim records As Records = tables.GetObjectRecords(Convert.ToUInt32(0), id, Constants.OpenMode.OpenForRead, False)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;' Iterate through all records&lt;BR /&gt;Dim record As Record = records.Item(0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'For Each record In records&lt;BR /&gt;Dim msg(12) As String&lt;/P&gt;&lt;P&gt;' Get the table&lt;BR /&gt;Dim table As ObjectData.Table = tables(record.TableName)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim str As String = Nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' Get record info&lt;BR /&gt;Dim i As Integer&lt;BR /&gt;Dim upbound As Integer = Record.Count - 1&lt;BR /&gt;For i = 2 To upbound - 1&lt;BR /&gt;Dim val As MapValue = Record(i)&lt;/P&gt;&lt;P&gt;Str = val.StrValue&lt;BR /&gt;msg(i - 1) = str&lt;BR /&gt;Next i&lt;BR /&gt;inWriter.WriteLine(pid &amp;amp; "," &amp;amp; y &amp;amp; "," &amp;amp; x &amp;amp; "," &amp;amp; z &amp;amp; "," &amp;amp; desc &amp;amp; "," &amp;amp; msg(1) &amp;amp; "," &amp;amp; msg(2) &amp;amp; "," &amp;amp; msg(3) &amp;amp; "," &amp;amp; msg(4) &amp;amp; "," &amp;amp; msg(5) &amp;amp; "," &amp;amp; msg(6) &amp;amp; "," &amp;amp; msg(7) &amp;amp; "," &amp;amp; msg(8) &amp;amp; "," &amp;amp; msg(9) &amp;amp; "," &amp;amp; msg(10) &amp;amp; "," &amp;amp; msg(11))&lt;BR /&gt;' Next&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Next n&lt;BR /&gt;inWriter.Flush()&lt;BR /&gt;inWriter.Dispose()&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2012 13:47:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3569884#M54001</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-08T13:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570168#M54002</link>
      <description>&lt;P&gt;If autocad wants to send a crash report, you can use the "View files" option and view the ".dmp" file.&amp;nbsp; Scroll down to the section called "appdata".&amp;nbsp; You &lt;U&gt;&lt;STRONG&gt;might&lt;/STRONG&gt;&lt;/U&gt; see some more info on where/why the crash occurs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the problem occurs&amp;nbsp;writing data to your csv file, you could try stringbuilder 1st.&amp;nbsp; Dump all of your point data into a stringbuilder, and then stream&amp;nbsp;that to file.&amp;nbsp; You could also&amp;nbsp;create large chunks with&amp;nbsp;stringbuilder and write the chunks to file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is just a guess - I think it is obvious your code is OK.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2012 15:34:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570168#M54002</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2012-08-08T15:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570842#M54003</link>
      <description>&lt;P&gt;do not know how to read the .dmp files. I tried using the stringbuilder and it did speed up the export but it still crashes with large amount of numbers. I did a little more debugging and found that most of the time it crashed when it gets to the &amp;nbsp;line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;oPoints = oAeccDB.Points&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried removing that line and replacing my first for statement with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Each oPoint In oAeccDB.Points&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then it crashed at that line. Anymore suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2012 20:55:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570842#M54003</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-08T20:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570870#M54004</link>
      <description>&lt;P&gt;Try create StringBulder and populate it with text lines&lt;/P&gt;&lt;P&gt;then write in in the csv file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sw.Write (sb.ToString());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Iow, do it separatelly&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>Wed, 08 Aug 2012 21:10:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570870#M54004</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-08-08T21:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570912#M54005</link>
      <description>&lt;P&gt;You can view the dmp file with the button at the bottom - I think it says "View file contents".&amp;nbsp; Select&amp;nbsp;the dmp file, then click on the view button.&amp;nbsp; It's been awhile since I have seen a crash report, but everything you need is on that dialog.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a map 3d user and have no experience with other verticals like Land Desktop.&amp;nbsp; Sorry!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2012 21:50:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570912#M54005</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2012-08-08T21:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570972#M54006</link>
      <description>&lt;P&gt;Thanks for your help finally got it to work with the stringbuilder. Here is my final code that worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;CommandMethod("exporter")&amp;gt; _&lt;BR /&gt;Public Sub ShowObjectDataInfo()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try&lt;BR /&gt;If oAcadApp Is Nothing Then&lt;BR /&gt;oAcadApp = GetObject(, "AutoCAD.Application")&lt;BR /&gt;End If&lt;BR /&gt;Catch ex As System.Exception&lt;BR /&gt;ed.WriteMessage(ex.Message)&lt;BR /&gt;End Try&lt;/P&gt;&lt;P&gt;oAeccApp = oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.9.0")&lt;BR /&gt;oAeccDoc = oAeccApp.ActiveDocument&lt;BR /&gt;oAeccDB = oAeccApp.ActiveDocument.Database&lt;/P&gt;&lt;P&gt;Dim CSV_FileName As String = Nothing&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;' navigate to the point text csv file using a file dialog&lt;BR /&gt;Dim dlg As New System.Windows.Forms.SaveFileDialog()&lt;BR /&gt;dlg.InitialDirectory = "C:\"&lt;BR /&gt;dlg.Filter = "csv excel files (*.csv)|*.csv|All files (*.*)|*.*"&lt;/P&gt;&lt;P&gt;If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then&lt;/P&gt;&lt;P&gt;CSV_FileName = dlg.FileName().ToString&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Dim oPoints As Autodesk.AECC.Interop.Land.AeccPoints&lt;BR /&gt;Dim sFilename As String&lt;BR /&gt;'Dim iCount As Integer&lt;/P&gt;&lt;P&gt;oPoints = oAeccDB.Points&lt;/P&gt;&lt;P&gt;sFilename = CSV_FileName&lt;BR /&gt;Dim builder As New StringBuilder&lt;BR /&gt;Dim inWriter As New StreamWriter(sFilename)&lt;BR /&gt;Dim desc As String&lt;BR /&gt;Dim pid As Integer&lt;BR /&gt;Dim x, y, z As Double&lt;/P&gt;&lt;P&gt;Dim oPoint As Autodesk.AECC.Interop.Land.AeccPoint = Nothing&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For Each oPoint In oAeccDB.Points&lt;BR /&gt;pid = oPoint.Number&lt;BR /&gt;x = oPoint.Easting&lt;BR /&gt;y = oPoint.Northing&lt;BR /&gt;z = oPoint.Elevation&lt;BR /&gt;desc = oPoint.RawDescription&lt;/P&gt;&lt;P&gt;Dim id As ObjectId = PointEntity.FromAcadObject(oPoint)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim tables As Tables&lt;BR /&gt;tables = HostMapApplicationServices.Application.ActiveProject.ODTables&lt;BR /&gt;Dim records As Records = tables.GetObjectRecords(Convert.ToUInt32(0), id, Constants.OpenMode.OpenForRead, False)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' Iterate through all records&lt;BR /&gt;Dim record As Record = records.Item(0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'For Each record In records&lt;BR /&gt;Dim msg(12) As String&lt;/P&gt;&lt;P&gt;' Get the table&lt;BR /&gt;Dim table As ObjectData.Table = tables(record.TableName)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim str As String = Nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' Get record info&lt;BR /&gt;Dim i As Integer&lt;BR /&gt;Dim upbound As Integer = record.Count - 1&lt;BR /&gt;For i = 2 To upbound - 1&lt;BR /&gt;Dim val As MapValue = record(i)&lt;/P&gt;&lt;P&gt;str = val.StrValue&lt;BR /&gt;msg(i - 1) = str&lt;BR /&gt;Next i&lt;BR /&gt;&lt;BR /&gt;builder.Append(pid &amp;amp; "," &amp;amp; y &amp;amp; "," &amp;amp; x &amp;amp; "," &amp;amp; z &amp;amp; "," &amp;amp; desc &amp;amp; "," &amp;amp; msg(1) &amp;amp; "," &amp;amp; msg(2) &amp;amp; "," &amp;amp; msg(3) &amp;amp; "," &amp;amp; msg(4) &amp;amp; "," &amp;amp; msg(5) &amp;amp; "," &amp;amp; msg(6) &amp;amp; "," &amp;amp; msg(7) &amp;amp; "," &amp;amp; msg(8) &amp;amp; "," &amp;amp; msg(9) &amp;amp; "," &amp;amp; msg(10) &amp;amp; "," &amp;amp; msg(11)).AppendLine()&lt;/P&gt;&lt;P&gt;Next&lt;BR /&gt;Dim s As String = builder.ToString&lt;BR /&gt;inWriter.WriteLine(s)&lt;BR /&gt;inWriter.Flush()&lt;BR /&gt;inWriter.Dispose()&lt;BR /&gt;builder.Clear()&lt;BR /&gt;GC.Collect()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2012 22:43:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570972#M54006</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-08T22:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570982#M54007</link>
      <description>&lt;P&gt;Just noticed another bug. The drawing closes out ok but when I try to close out of Civil3d after running my command it crashes. Is there something that I am not closing or disposing of properly?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2012 23:04:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3570982#M54007</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-08T23:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3571214#M54008</link>
      <description>&lt;P&gt;I recommend you&amp;nbsp;to use in your code the following syntax&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Use Try ... Catch .. finally code block, it allow you to find&lt;/P&gt;&lt;P&gt;the problem points of code&amp;nbsp;easily&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- use Using.. End Using for all non-resident objects, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using sw as SreamWriter= ....&lt;/P&gt;&lt;P&gt;sw.Write(...)&lt;/P&gt;&lt;P&gt;end using '' no need to close or dispose&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;same way for StringBuilder, i that case you don't have to Dispose&lt;/P&gt;&lt;P&gt;both of them as well&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>Thu, 09 Aug 2012 06:18:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3571214#M54008</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-08-09T06:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3571328#M54009</link>
      <description>&lt;P&gt;I just imagine how it would be, coz I haven't have Civil3d on my end&lt;/P&gt;&lt;P&gt;See code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    &amp;lt;CommandMethod("exporter")&amp;gt; _
    Public Sub ShowObjectDataInfo()
        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
        Dim oAcadApp As AcadApplication = Application.AcadApplication

        Try
            If oAcadApp Is Nothing Then
                oAcadApp = GetObject(, "AutoCAD.Application")
            End If
        Catch ex As System.Exception
            ed.WriteMessage(ex.Message)
        End Try

        oAeccApp = oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.9.0")
        oAeccDoc = oAeccApp.ActiveDocument
        oAeccDB = oAeccApp.ActiveDocument.Database

        Dim CSV_FileName As String = Nothing

        Try
            ' navigate to the point text csv file using a file dialog
            Dim dlg As New System.Windows.Forms.SaveFileDialog()
            dlg.InitialDirectory = "C:\"
            dlg.RestoreDirectory = True
            dlg.Filter = "csv excel files (*.csv)|*.csv|All files (*.*)|*.*"

            If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then

                CSV_FileName = dlg.FileName().ToString
            End If

            Dim oPoints As Autodesk.AECC.Interop.Land.AeccPoints
            Dim sFilename As String
            Dim iCount As Integer

            oPoints = oAeccDB.Points

            sFilename = CSV_FileName
            Dim builder As New StringBuilder

            Dim desc As String
            Dim pid As Integer
            Dim x, y, z As Double


            For Each oPoint In oAeccDB.Points

                pid = oPoint.Number
                x = oPoint.Easting
                y = oPoint.Northing
                z = oPoint.Elevation
                desc = oPoint.RawDescription

                Dim id As ObjectId = PointEntity.FromAcadObject(oPoint)


                Dim tables As Tables
                tables = HostMapApplicationServices.Application.ActiveProject.ODTables
                Dim records As Records = tables.GetObjectRecords(Convert.ToUInt32(0), id, Constants.OpenMode.OpenForRead, False)



                ' Iterate through all records
                Dim record As Record = records.Item(0)



                For Each record In records
                    Dim msg(12) As String

                    ' Get the table
                    Dim table As ObjectData.Table = tables(record.TableName)


                    Dim str As String = Nothing



                    ' Get record info
                    Dim i As Integer
                    Dim upbound As Integer = record.Count - 1
                    For i = 2 To upbound - 1
                        Dim val As MapValue = record(i)

                        str = val.StrValue
                        msg(i - 1) = str()
                    Next i

                    Dim rec As String = String.Format("{0}" + vbTab + "{1}" + vbTab + "{2}" + vbTab + "{3}" + vbTab + _
                                                      "{4}" + vbTab + "{5}" + vbTab + "{6}" + vbTab + "{7}" + vbTab + _
                                                      "{8}" + vbTab + "{9}" + vbTab + "{10}" + vbTab + "{11}" + vbTab + _
                                                      "{12}" + vbTab + "{13}" + vbTab + "{14}" + vbTab + "{15}",
                                                      pid, y, x, z, desc, msg(1), msg(2), msg(3), msg(4), msg(5), msg(6),
                                                      msg(7), msg(8), msg(9), msg(10), msg(11))
                    builder.AppendLine(rec)

                Next

                Using inWriter As New StreamWriter(sFilename)
                    inWriter.WriteLine(builder.ToString)
                    inWriter.Flush()
                End Using
                GC.Collect()

        Catch ex As System.Exception
            MsgBox(ex.Message + vbLf + ex.StackTrace)
        Finally

        End Try

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&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>Thu, 09 Aug 2012 08:00:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3571328#M54009</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-08-09T08:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3572436#M54010</link>
      <description>&lt;P&gt;That works great thanks for the code!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2012 17:30:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3572436#M54010</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-09T17:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing when exporting large amount of points to csv vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3572456#M54011</link>
      <description>&lt;P&gt;Glad to help,&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;</description>
      <pubDate>Thu, 09 Aug 2012 17:38:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/crashing-when-exporting-large-amount-of-points-to-csv-vb-net/m-p/3572456#M54011</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-08-09T17:38:57Z</dc:date>
    </item>
  </channel>
</rss>

