AutoCAD Civil 3D Customization

AutoCAD Civil 3D Customization

Reply
Mentor
MarkPendergraft
Posts: 385
Registered: ‎06-27-2005
Message 1 of 4 (986 Views)
Accepted Solution

Feature Line and SurveyFigure bulge

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

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

                    sFig.Erase()

                    ms.AppendEntity(pl)
                    trans.AddNewlyCreatedDBObject(pl, True)
                End If
            Next

            trans.Commit()
        End Using

    End Sub

 

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 -

 

http://adndevblog.typepad.com/infrastructure/2013/01/convert-civil-3d-surveyfigure-to-polyline-object.html

 

Hope this helps.

Partha,

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.

 

Sincerely,

-Mark P.

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.

 

Cheers,

Partha

ADN

ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 2 of 4 (967 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 -

 

http://adndevblog.typepad.com/infrastructure/2013/01/convert-civil-3d-surveyfigure-to-polyline-objec...

 

Hope this helps.



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Mentor
MarkPendergraft
Posts: 385
Registered: ‎06-27-2005
Message 3 of 4 (960 Views)

Re: Feature Line and SurveyFigure bulge

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

Partha,

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.

 

Sincerely,

-Mark P.

ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 4 of 4 (951 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.

 

Cheers,

Partha

ADN



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

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.