AutoCAD Civil 3D Customization

AutoCAD Civil 3D Customization

Reply
Contributor
mikekillion
Posts: 23
Registered: ‎10-01-2009
Message 1 of 6 (337 Views)

Point Elevation not Point Location Z

337 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

 

*Expert Elite*
Jeff_M
Posts: 4,519
Registered: ‎07-22-2003
Message 2 of 6 (336 Views)

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
Contributor
mikekillion
Posts: 23
Registered: ‎10-01-2009
Message 3 of 6 (334 Views)

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.

*Expert Elite*
Jeff_M
Posts: 4,519
Registered: ‎07-22-2003
Message 4 of 6 (331 Views)

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
Contributor
mikekillion
Posts: 23
Registered: ‎10-01-2009
Message 5 of 6 (329 Views)

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

Contributor
mikekillion
Posts: 23
Registered: ‎10-01-2009
Message 6 of 6 (321 Views)

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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.