- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Dim CSV_FileName As String = Nothing
' navigate to the point text csv file using a file dialog
Dim dlg As New System.Windows.Forms.SaveFileDialog()
dlg.InitialDirectory = "C:\"
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 inWriter As New StreamWriter(sFilename)
Dim pid, desc As String
Dim x, y, z As Double
Dim oPoint As Autodesk.AECC.Interop.Land.AeccPoint
Dim cnt As Long = oPoints.Count
Dim expline(cnt) As String
Dim n As Long
For n = 0 To cnt - 1
oPoint = oPoints.Item(n)
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
inWriter.WriteLine(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))
' Next
Next n
inWriter.Flush()
inWriter.Dispose()
End Sub
Solved! Go to Solution.