Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Point Elevation not Point Location Z

5 REPLIES 5
Reply
Message 1 of 6
mikekillion
538 Views, 5 Replies

Point Elevation not Point Location Z

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 Sub

 Thank you,

 

Mike

 

5 REPLIES 5
Message 2 of 6
Jeff_M
in reply to: mikekillion

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.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 6
mikekillion
in reply to: Jeff_M

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.

Message 4 of 6
Jeff_M
in reply to: mikekillion

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.

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 6
mikekillion
in reply to: Jeff_M

Thanks Jeff. I knew I was missing something. I will give that a try.

 

MIke

Message 6 of 6
mikekillion
in reply to: mikekillion

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 Sub

 I 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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report