Convert Arc to polyline
CSGemini
5/24/2022 7:53 AM
|
---|
I'm struggling a bit with this. I have tried adapting a few similar forum posts without success. Basically I have a number of items in the cad file, lines and arcs. I can convert a series of connected lines to a polyline without problem. The issue is when i come across a line that connects to an arc. Do we have an example of converting an arc to a polyline ?
|
Wout
5/24/2022 8:09 AM
|
---|
Hi,
The vertex Bulge property defines the curvature, the documentation should provide all the information you need, including references to methods to calculate the Bulge value.
- Wout
|
CSGemini
5/24/2022 8:11 AM
|
---|
I did find the below code in a netDxf library which worked really well in that library and was trying to adapt it for Cadlib but not finding it that easy to map the objects between libraries:
C# Code: internal class ArcToPolyLine
{
/ |
Wout
5/24/2022 8:23 AM
|
---|
This code is approximating an arc with line segments. I assume you want to retain the actual arcs.
My best advice is still reading the vertex Bulge property documentation and following the leads.
- Wout
|
CSGemini
5/24/2022 8:27 AM
|
---|
Thanks. I'm starting to see where you are coming from now and getting some better results.
|
CSGemini
5/24/2022 9:49 AM
|
---|
So building on your suggestion I came up with this. Needs a little more work to take into account clockwise or counter clockwise and a few other bits but you probably get the jist of it:
var a = (DxfArc)i;
DxfPolyline2D polyarc = new DxfPolyline2D();
polyarc.Vertices.Add(a.GetXStart(), a.GetYStart());
polyarc.Vertices.Add(a.GetXEnd(), a.GetYEnd());
polyarc.Vertices[0].Bulge = GetArcBulge(a);
pl.Vertices.AddRange(polyarc.Vertices);
The only issue i see is that the polyline seems to lack a bit of precision. In the attached the white line is the polyline with the buldge and the red the original arc. The arc is smoother. Any pointers on how to improve on that.....
|
Wout
5/24/2022 9:57 AM
|
---|
Hi,
You could increase GraphicsConfig.NoOfArcLineSegments, but this is at the cost of performance/memory usage.
- Wout
|