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: 

Feature Line and SurveyFigure bulge

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
MarkPendergraft
1720 Views, 4 Replies

Feature Line and SurveyFigure bulge

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

 

4 REPLIES 4
Message 2 of 5

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

Message 3 of 5

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.

Message 4 of 5

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

Message 5 of 5

This question has come up again, so I thought I would clarify the logic behind the final program used in order to solve some of the issues I ran into while trying to get 2d polylines from survey figures.  I found the best results from the following process:

 

  1. Open the survey database and get every survey figure associated with it (using the COM interop libraries). The COM libraries let you read the bulges for survey figures.
  2. Get every survey figure in the drawing using the .NET libraries
  3. Ask the user if they want to leave survey figures marked as breaklines as actual survey figures.
  4. Ask the user which layer they would like to leave the survey figures marked as breaklines on
  5. Go through every survey figure in the drawing, and find the matching COM survey figure
  6. Draw a new 2d polyline using the vertices and bulges from the COM survey figure, use the layer information from the drawing figure obtained via .NET
  7. A) If the COM figure is marked as a breakline AND the figure is on the user specified breakline layer then do nothing B) If the COM figure is marked as a breakline AND the figure is NOT on the user specified breakline layer, then change the survey figure to the user breakline layer C) If the COM figure is NOT marked as a breakline, then delete the survey figure from the drawing completely.

 

I leave the survey figures alone in the actual survey database, so the user could theoretically re-import them if needed.

 

-Mark P.

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

Post to forums  

Rail Community


Autodesk Design & Make Report