fix: convert arc angles from radians to degrees in DrawingDxfExporter

ACadSharp Arc.StartAngle/EndAngle store values in degrees (DXF spec groups
50/51). The previous code passed Math.Atan2 results (radians) directly,
causing silent geometry corruption. Also hardened the arc export test to
assert angles are in degree range (0..360).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
aj
2026-06-23 06:53:17 -04:00
co-authored by Claude Sonnet 4.6
parent af07946a79
commit 7a4a35da55
2 changed files with 8 additions and 3 deletions
@@ -59,5 +59,9 @@ public class DrawingDxfExporterTests
var arcs = doc.Entities.OfType<ACadSharp.Entities.Arc>().ToList();
Assert.Single(lines);
Assert.Single(arcs);
var arc = doc.Entities.OfType<ACadSharp.Entities.Arc>().Single();
// Angles must be in degrees (0..360), not radians (0..6.28)
Assert.InRange(arc.StartAngle, 0, 360);
Assert.InRange(arc.EndAngle, 0, 360);
}
}
+4 -3
View File
@@ -1,4 +1,4 @@
using ACadSharp;
using ACadSharp;
using ACadSharp.IO;
using ACadSharp.Tables;
using CSMath;
@@ -77,8 +77,8 @@ public static class DrawingDxfExporter
{
Center = ToXYZ(arcCenter),
Radius = radius,
StartAngle = startAngle,
EndAngle = endAngle,
StartAngle = startAngle * (180.0 / Math.PI),
EndAngle = endAngle * (180.0 / Math.PI),
Layer = layer
});
}
@@ -104,3 +104,4 @@ public static class DrawingDxfExporter
private static XYZ ToXYZ(Vector v) => new XYZ(v.X, v.Y, 0);
}