AutoCAD Civil 3D Customization

Posts: 375
Registered: ‎06-27-2005
Message 1 of 4 (458 Views)
Accepted Solution

Feature Line and SurveyFigure bulge

458 Views, 3 Replies
01-20-2013 08:29 PM

I'm trying to convert a SurveyFigure into a 2d polyline WITH the curves intact in .NET.  When I get the baseCurve, it returns a polyline3d, which only contains 3d line segments.  I've looked through the API documentation and can't figure out how to get the bulge of the vertices within the SurveyFigure (or of it's derived class, a FeatureLine).


Now, I am able to use the COM API to get this information and to create a 2d polyline with the curve information, but using the COM methods means accessing the survey figures through the survey database and not the drawing, and that opens up a whole new set of problems.


I know a few people said on a post in this forum that finding the bulges was possible through math, but the only way I can think of doing that is to write a function to look for evenly spaced vertices, then back up when they are found and figure out the bulge from the chord and the points along the curve.


I'm assuming that I'm missing something and would appreciate a nudge in the right direction.


-Mark P.


Sample code:

    <CommandMethod("EXTRACTFIGURES")> Public Sub ExtractSurveyFigure()
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
        Dim pSelOpt As PromptSelectionOptions = New PromptSelectionOptions
        pSelOpt.MessageForAdding = vbCrLf + "Select Figures: "

        Dim pSelRes As PromptSelectionResult = ed.GetSelection(pSelOpt)

        If pSelRes.Status <> PromptStatus.OK Then Exit Sub

        Using trans As Transaction = ed.Document.Database.TransactionManager.StartTransaction

            Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite)
            Dim ms As BlockTableRecord = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            Dim sFig As SurveyFigure
            Dim ent As Autodesk.AutoCAD.DatabaseServices.Entity
            Dim pl As Polyline2d

            For Each id As ObjectId In pSelRes.Value.GetObjectIds
                ent = trans.GetObject(id, OpenMode.ForWrite)
                If TypeOf (ent) Is SurveyFigure Then
                    sFig = ent

                    Dim pnts As New Point3dCollection
                    Dim pnt As Point3d
                    Dim bulges As New DoubleCollection
                    For i As Double = 0.0 To sFig.BaseCurve.EndParam Step 1.0
                        pnt = sFig.BaseCurve.GetPointAtParameter(i)
                        pnts.Add(New Point3d(pnt.X, pnt.Y, 0))
                        bulges.Add(0) 'can't figure out how to get the bulge, so just create a line at this point.

                    pl = New Polyline2d(Poly2dType.SimplePoly, pnts, 0.0, sFig.BaseCurve.Closed, 0.0, 0.0, bulges)
                    pl.Layer = sFig.Layer


                    trans.AddNewlyCreatedDBObject(pl, True)
                End If

        End Using

    End Sub


ADN Support Specialist
Posts: 543
Registered: ‎06-09-2009
Message 2 of 4 (439 Views)

Re: Feature Line and SurveyFigure bulge

01-22-2013 12:35 AM in reply to: MarkPendergraft

Hi Mark,


I didn't try to debug your application to check what's happening with bulges.Add(0), but if you are trying to convert SurveyFigure into a 2d polyline WITH the curves intact in .NET, you can use survFig.BaseCurve.GetProjectedCurve(plane, dir) function. Please take a look into the following blog post -


Hope this helps.

Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Posts: 375
Registered: ‎06-27-2005
Message 3 of 4 (432 Views)

Re: Feature Line and SurveyFigure bulge

01-22-2013 08:02 AM in reply to: Partha.Sarkar


Thank you for your response.  I tried the method you recommended and came up with the same results.  Line segments in place of the curves.  However, knowing that your code in the link you provided was working (at least in some situations) led me to the answer.  If I want to maintain the arc segment information when creating the curve, I first need to flatten the elevation of the survey figure.  At that point, I have created a 2D survey figure, and when I get the base curve, it basically returns a 2d polyline.


Again, thank you for pointing me in the right direction.  I can definitely use this info to achieve what I am after.



-Mark P.

ADN Support Specialist
Posts: 543
Registered: ‎06-09-2009
Message 4 of 4 (423 Views)

Re: Feature Line and SurveyFigure bulge

01-22-2013 08:57 PM in reply to: MarkPendergraft

Thanks Mark ! I am glad to help you here.


I am adding the point you mentioned in the Blog post here for the benefit of Civil 3D Forum visitors -

To get the base curve from SurveyFigure we can simple get the BaseCurve and add that to DWG database using AddNewlyCreatedDBObject(). GetProjectedCurve() is redundant here, unless someone want to project the baseCurve to a plane other than world.





Partha Sarkar
Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community

Civil 3D Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for AutoCAD Civil 3D helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Civil 3D