• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    AutoCAD Civil 3D Customization

    Reply
    Contributor
    Posts: 20
    Registered: ‎10-01-2009

    Point Elevation not Point Location Z

    255 Views, 5 Replies
    08-10-2011 02:59 PM

    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

     

    Please use plain text.
    *Expert Elite*
    Posts: 3,043
    Registered: ‎07-22-2003

    Re: Point Elevation not Point Location Z

    08-10-2011 03:27 PM 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
    Please use plain text.
    Contributor
    Posts: 20
    Registered: ‎10-01-2009

    Re: Point Elevation not Point Location Z

    08-10-2011 03:31 PM 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.

    Please use plain text.
    *Expert Elite*
    Posts: 3,043
    Registered: ‎07-22-2003

    Re: Point Elevation not Point Location Z

    08-10-2011 05:27 PM 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
    Please use plain text.
    Contributor
    Posts: 20
    Registered: ‎10-01-2009

    Re: Point Elevation not Point Location Z

    08-10-2011 05:29 PM in reply to: Jeff_M

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

     

    MIke

    Please use plain text.
    Contributor
    Posts: 20
    Registered: ‎10-01-2009

    Re: Point Elevation not Point Location Z

    08-10-2011 11:38 PM 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.

    Please use plain text.