/// <summary>
/// Creates a polyline from a profile, does not support true vertical curves but tesselates along them at 1', or 0.3m, increments.
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public static Polyline GetPolylineFromProfile(this Profile profile)
{
Polyline pline
= new Polyline
();
var civDoc = CivilApplication.ActiveDocument;
double tesslationDistance = 1;
if (civDoc.DrawingUnitsAreMeters()) //this is another simple extension method
tesslationDistance = 0.3;
foreach (var pvi in profile.PVIs)
{
switch (pvi.PVIType)
{
case ProfileEntityType.Circular:
case ProfileEntityType.ParabolaAsymmetric:
case ProfileEntityType.ParabolaSymmetric:
double currentTesslationStation = pvi.VerticalCurve.StartStation;
while (currentTesslationStation < pvi.VerticalCurve.EndStation)
{
double elevAtTesslationStation = profile.ElevationAt(currentTesslationStation);
pline
.AddVertexAt(pline
.NumberOfVertices,
new Point2d
(currentTesslationStation, elevAtTesslationStation
),
0,
0,
0); currentTesslationStation += tesslationDistance;
}
pline
.AddVertexAt(pline
.NumberOfVertices,
new Point2d
(pvi
.VerticalCurve.EndStation, pvi
.VerticalCurve.EndElevation),
0,
0,
0); break;
case ProfileEntityType.None:
case ProfileEntityType.Tangent:
pline
.AddVertexAt(pline
.NumberOfVertices,
new Point2d
(pvi
.Station, pvi
.Elevation),
0,
0,
0); break;
default:
break;
}
}
return pline;
}