AutoCAD Civil 3D Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Point Elevation not Point Location Z
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I am trying to write a routine that exports point to a CSV file. I would like the Point Elevation, but I only see the Z location property. Here is the code. Often our points are at a elevation of zero, but the elevation property is at the design grade, so the Location would not be correct. What am I missing?
<CommandMethod("ExportPoints")> _
Public Sub ExportPointsToCSV()
Dim myDoc As Document = AcadNETApp.DocumentManager.MdiActiveDocument
Dim myCivilDoc As Autodesk.Civil.ApplicationServices.CivilDocument
myCivilDoc = CivilApplicationManager.ActiveCivilDocument
Dim mySW As New IO.StreamWriter("C:\test.csv")
Using myTrans As Transaction = myDoc.TransactionManager.StartTransaction
For Each myPointID As ObjectId In myCivilDoc.GetAllPointIds
Dim myPoint As PointEntity = myPointID.GetObject(OpenMode.ForRead)
mySW.WriteLine(myPoint.PointNumber & "," & _
myPoint.Location.Y.ToString & "," & _
myPoint.Location.X.ToString & "," & _
myPoint.Location.Z.ToString & "," & _
Left(myPoint.FullDescription, 15))
Next
End Using
mySW.Flush()
mySW.Close()
mySW.Dispose()
End SubThank you,
Mike
Re: Point Elevation not Point Location Z
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
The Z is the point's elevation. Where it is displayed in the drawing is controlled by the style, so the Location.Z should never change due to how it's displayed.
Re: Point Elevation not Point Location Z
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks for taking a look at this Jeff.
When I select a point in the drawing and view the properties, it shown me a northing, easting and elevation. When I run this routine, the elevation of every point is 0, regardless of the elevation shown in the properties dialog. How do I retrieve the point elevation displayed in the drawing?
Mike.
Re: Point Elevation not Point Location Z
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Oops, sorry about that! I really should learn to not post when I'm in a hurry.
The PointEntity is a newer (2011) addition to the .NET API and it appears it is not completely done. I've always used the COM API to get the elevation which IS a property of the AeccPoint object.
Re: Point Elevation not Point Location Z
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks Jeff. I knew I was missing something. I will give that a try.
MIke
Re: Point Elevation not Point Location Z
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks again Jeff. That was the guidance I needed.and I was able to get the code below to work.
<CommandMethod("ExportPoints")> _
Public Sub ExportPointsToCSV()
'This routine still relies on the COM Interface in order to get the Point elevation, not the location
Dim myDoc As Document = AcadNETApp.DocumentManager.MdiActiveDocument
Dim myCivilDoc As AeccDocument
myCivilDoc = CivilApplicationManager.COMActiveCivilDocument
Dim myProjectInformation(2) As String
myProjectInformation = myAcadApp.getProjectInformation(myDoc)
Dim sPath As String = myProjectInformation(2) & "\08 Site Construction\Point Files\" & myProjectInformation(1) & "." & Now().ToString("yyyy-MM-dd") & ".csv"
MsgBox(sPath)
Dim mySW As New IO.StreamWriter(sPath)
Dim myPoints As AeccPoints = myCivilDoc.Points
Using myTrans As Transaction = myDoc.TransactionManager.StartTransaction
For Each myPoint As AeccPoint In myCivilDoc.Points
mySW.WriteLine(myPoint.Number & "," & _
myPoint.Northing & "," & _
myPoint.Easting & "," & _
myPoint.Elevation & "," & _
Left(myPoint.FullDescription, 15))
Next
End Using
mySW.Flush()
mySW.Close()
mySW.Dispose()
End SubI did notice that the resulting file was not in point number order. Is there a way to easily retrieve the myCivilDoc.Points collection already sorted without assigning it to an array?
Thanks again. I'd been struggling with that for far longer than I hoped, and I finally worked through the COM .NET confusion I have had in migrating from VBA.

