From 7a4a35da55049ad2ac545885655fc5b5ccdee1dd Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 23 Jun 2026 06:53:17 -0400 Subject: [PATCH] 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 --- PepLib.Core.Tests/IO/DrawingDxfExporterTests.cs | 4 ++++ PepLib.Core/IO/DrawingDxfExporter.cs | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PepLib.Core.Tests/IO/DrawingDxfExporterTests.cs b/PepLib.Core.Tests/IO/DrawingDxfExporterTests.cs index 35509a8..bb6492c 100644 --- a/PepLib.Core.Tests/IO/DrawingDxfExporterTests.cs +++ b/PepLib.Core.Tests/IO/DrawingDxfExporterTests.cs @@ -59,5 +59,9 @@ public class DrawingDxfExporterTests var arcs = doc.Entities.OfType().ToList(); Assert.Single(lines); Assert.Single(arcs); + var arc = doc.Entities.OfType().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); } } diff --git a/PepLib.Core/IO/DrawingDxfExporter.cs b/PepLib.Core/IO/DrawingDxfExporter.cs index 4eeb0f4..917bc8b 100644 --- a/PepLib.Core/IO/DrawingDxfExporter.cs +++ b/PepLib.Core/IO/DrawingDxfExporter.cs @@ -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); } +