- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to create a Polyline from a list of Curve objects, my list contains Lines and Arcs, these curves are not in the document, I'm creating then by code. I managed to generated a Polyline usingthe points of these curves and adding as a Vertex to the Polyline, it works but I have a problem with my loops.
I tried different ways to generate the vertex, using both start and end points of the curves generated extra lines with equal start and end points, using only the start point but arcs are not correctly generated, then I tried to verify if the point already exists before adding as a vertex on the code bellow, but it creates a extra line on arcs.
Has someone managed to generated something like this that can help me? Thanks in advance.
private Polyline CurvesToPolyline(List<Curve> curves, bool closed)
{
// Cria uma Polyline
Polyline pline = new Polyline();
// Transforma as curvas em elementos da Polyline
for (int i = 0; i < curves.Count; i++)
{
Curve curve = curves[i];
if (curve is Line)
{
Line line = (Line)curve;
if (i == 0 || !line.StartPoint.IsEqualTo(pline.GetPoint3dAt(pline.NumberOfVertices - 1)))
{
pline.AddVertexAt(pline.NumberOfVertices, new Point2d(line.StartPoint.X, line.StartPoint.Y), 0.0, 0.0, 0.0);
}
pline.AddVertexAt(pline.NumberOfVertices, new Point2d(line.EndPoint.X, line.EndPoint.Y), 0.0, 0.0, 0.0);
}
else if (curve is Arc)
{
Arc arc = (Arc)curve;
if (i == 0 || !arc.StartPoint.IsEqualTo(pline.GetPoint3dAt(pline.NumberOfVertices - 1)))
{
pline.AddVertexAt(pline.NumberOfVertices, new Point2d(arc.StartPoint.X, arc.StartPoint.Y), GetArcBulge(arc), 0.0, 0.0);
}
pline.AddVertexAt(pline.NumberOfVertices, new Point2d(arc.EndPoint.X, arc.EndPoint.Y), 0.0, 0.0, 0.0);
}
}
if (closed)
{
pline.Closed = true;
}
return pline;
}
Solved! Go to Solution.