If you have a requirement to convert polyline to Civil 3D Alignment object programmatically i.e. using Civil 3D API, you are at the right place :)
This VB.NET code snippet demonstrates how to create (or convert) a Polyline to a Civil 3D Alignment object.
' Select the Polyline
Dim promptEntOp As New PromptEntityOptions(vbCrLf + "Select a Polyline : ")
Dim promptEntRs As PromptEntityResult
promptEntRs = ed.GetEntity(promptEntOp)
If promptEntRs.Status <> PromptStatus.OK Then
ed.WriteMessage("Exiting! Try Again !")
Exit Sub
End If
Dim idEnt As ObjectId = promptEntRs.ObjectId
Try
Dim poptions As Autodesk.Civil.DatabaseServices.PolylineOptions
poptions.AddCurvesBetweenTangents = True
poptions.EraseExistingEntities = True
poptions.PlineId = idEnt
' Check the Alignment Style Name and labelSetName
' To use the following default names you can use the "Align-6A.dwg " from Help\Civil Tutorials\Drawings\
' and make sure to create a empty Site named "Site 1"(if it is already not there in the DWG file), also draw a polyline to convert it to Alignment.
Dim alignId As ObjectId = Nothing
alignId = Alignment.Create(civilDoc, poptions, "Test_Alignment", "Site 1", "0", "Design Style", "All Labels")
trans.Commit()
Once you build your application using the above code snippet and run the custom command in Civil 3D 2013, you should see the Alignment created (like below ) :
Hope this helps!