I am trying to write a program that will dump a points list in PNEZD (CSV) format into a text file and then display the text file. The program works but the points aren't in numerical order. I simply did a "for each Point in Points" loop. Is there an easy way to sort these? Or am I going to have to resort to using a list. And if I did use the list, what would be the simplest way to do this. Dump all of the points into an array and use the array index matched with the point number in my key-value pair? I'm open to suggestions. Thanks in advance!
Imports System
Imports Autodesk
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports AcadNET = Autodesk.AutoCAD
Imports AcadCOM = Autodesk.AutoCAD.Interop
Imports AcadNETApp = Autodesk.AutoCAD.ApplicationServices.Application
Imports AeccLandLib = Autodesk.AECC.Interop.Land
Imports AeccUiLandLib = Autodesk.AECC.Interop.UiLand
Imports AecUIBase = Autodesk.AEC.Interop.UIBase
Namespace MyUtils
Public Class Commands
Private oAcadApp As AcadCOM.AcadApplication
Private oAeccApp As AeccUiLandLib.IAeccApplication
Private oAeccDoc As AeccUiLandLib.IAeccDocument
Private oAeccDb As AeccLandLib.IAeccDatabase
<CommandMethod("PTLIST")> _
Public Sub DisplayPointList()
Dim ed As Editor = AcadNETApp.DocumentManager.MdiActiveDocument.Editor
oAcadApp = AcadNETApp.AcadApplication
oAeccApp = oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.5.0")
oAeccDoc = oAeccApp.ActiveDocument
oAeccDb = oAeccApp.ActiveDocument.Database
Try
Dim oPoints As AeccLandLib.AeccPoints
Dim oPoint As AeccLandLib.AeccPoint
Dim oToFile As System.IO.TextWriter
oToFile = System.IO.File.CreateText("C:\points.txt")
oPoints = oAeccDb.Points
For Each oPoint In oPoints
If oPoint.Elevation < -999999 Then oPoint.Elevation = "0"
oToFile.WriteLine(oPoint.Number & "," & oPoint.Northing & "," & oPoint.Easting & "," & oPoint.Elevation & "," & oPoint.RawDescription & "")
Next
oToFile.Flush()
oToFile.Close()
oAcadApp = Nothing
oAeccApp = Nothing
oAeccDoc = Nothing
oAeccDb = Nothing
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage("Error: ", ex.Message & vbCrLf)
End Try
Process.Start("notepad.exe", "C:\points.txt")
End Sub
End Class
End Namespace