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.
<CommandMethod("EXTRACTFIGURES")> Public Sub ExtractSurveyFigure() Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Edit
or Dim db As Database = Application.DocumentManager.MdiActiveDocument.Data base 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.StartTrans action 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
Solved! Go to Solution.
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.
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.
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.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.