diff --git a/AGENTS.md b/AGENTS.md
index b711149a..493010df 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -65,7 +65,7 @@ Releases: follow [the release procedure](docs/releasing.md) and `scripts/Publish
Read the relevant contract before changing its behavior:
- [Nest file format](docs/nest-file-format.md)
-- [SVG import and export](docs/svg-import-export.md): SVG numbers are not drawing units; import never guesses a scale
+- [SVG import and export](docs/svg-import-export.md): SVG numbers are not drawing units; import never guesses a scale. It also covers the CAD Converter's DXF/DWG/SVG export, whose bends import reads back
- [Irregular stock](docs/irregular-stock.md): outlined sheets, what honors the outline and what refuses it
- [Directional slides](docs/geometry/directional-slides.md) and [pair-spacing limits](docs/geometry/pair-spacing.md)
- [Lead-in placement](docs/geometry/lead-in-placement.md) (including the planner's eroded pierce for cutouts too small for their lead-in and the stop at a feature's center line) and [pierce zones](docs/geometry/pierce-zone.md): opt-in `PierceDiameter` clearance, the hole pole fallback and the planner's perimeter scrap fallback
diff --git a/OpenNest.IO/Bending/BendNote.cs b/OpenNest.IO/Bending/BendNote.cs
new file mode 100644
index 00000000..1dcaed08
--- /dev/null
+++ b/OpenNest.IO/Bending/BendNote.cs
@@ -0,0 +1,71 @@
+using System.Globalization;
+using OpenNest.Bending;
+using OpenNest.Geometry;
+using OpenNest.Math;
+
+namespace OpenNest.IO.Bending
+{
+ ///
+ /// The note an export writes beside a bend line, in the form
+ /// reads back ("UP 90° R 0.06").
+ ///
+ internal static class BendNote
+ {
+ ///
+ /// The bend's own note when it has one, otherwise one built from its direction, angle
+ /// and radius; null when the direction is unknown, since the detector pairs a note with
+ /// its line by the word UP or DOWN.
+ ///
+ public static string Text(Bend bend)
+ {
+ if (!string.IsNullOrWhiteSpace(bend.NoteText))
+ return bend.NoteText;
+
+ var direction = bend.Direction switch
+ {
+ BendDirection.Up => "UP",
+ BendDirection.Down => "DOWN",
+ _ => null,
+ };
+ if (direction == null)
+ return null;
+
+ var text = direction;
+ if (bend.Angle.HasValue)
+ text += $" {Number(bend.Angle.Value)}°";
+ if (bend.Radius.HasValue)
+ text += $" R {Number(bend.Radius.Value)}";
+ return text;
+ }
+
+ /// A readable text height; the detector accepts a note within two heights of its line.
+ public static double Height(Units units) => units == Units.Millimeters ? 3.0 : 0.125;
+
+ ///
+ /// Where the note sits: just off the middle of the line, turned along it so it reads
+ /// left to right. The angle is in radians.
+ ///
+ public static (Vector Position, double Angle) Placement(Bend bend, double height)
+ {
+ var angle = bend.StartPoint.AngleTo(bend.EndPoint);
+ if (angle > Angle.HalfPI + Tolerance.Epsilon)
+ angle -= System.Math.PI;
+ else if (angle <= -Angle.HalfPI + Tolerance.Epsilon)
+ angle += System.Math.PI;
+
+ var gap = height * 0.25;
+ var middle = new Vector(
+ (bend.StartPoint.X + bend.EndPoint.X) / 2,
+ (bend.StartPoint.Y + bend.EndPoint.Y) / 2
+ );
+ var position = new Vector(
+ middle.X - PortableMath.Sin(angle) * gap,
+ middle.Y + PortableMath.Cos(angle) * gap
+ );
+ return (position, angle);
+ }
+
+ private static string Number(double value) =>
+ value.ToString("0.######", CultureInfo.InvariantCulture);
+ }
+}
diff --git a/OpenNest.IO/CadExporter.cs b/OpenNest.IO/CadExporter.cs
new file mode 100644
index 00000000..35356d29
--- /dev/null
+++ b/OpenNest.IO/CadExporter.cs
@@ -0,0 +1,283 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using ACadSharp;
+using ACadSharp.Entities;
+using ACadSharp.IO;
+using ACadSharp.Tables;
+using ACadSharp.Types.Units;
+using CSMath;
+using OpenNest.Bending;
+using OpenNest.Geometry;
+using OpenNest.IO.Bending;
+using OpenNest.Math;
+using AcadLayer = ACadSharp.Tables.Layer;
+using GeoEntity = OpenNest.Geometry.Entity;
+
+namespace OpenNest.IO
+{
+ ///
+ /// Writes a drawing's source entities and bends as DXF, DWG or SVG, so that
+ /// reads the same geometry and bends back. Each entity keeps its
+ /// layer; bends go on BEND as center lines with a note in the form the bend detector
+ /// reads. Bend-source lines are written only as their bends.
+ ///
+ public static class CadExporter
+ {
+ public const string BendLayerName = "BEND";
+
+ ///
+ /// The DWG versions that read back as written. ACadSharp cannot write DWG 2007 (AC1021),
+ /// and its DWG 2000 (AC1015) and R14 (AC1014) output loses entities and their layers.
+ ///
+ public static readonly IReadOnlyList DwgVersions = new[]
+ {
+ ACadVersion.AC1032,
+ ACadVersion.AC1027,
+ ACadVersion.AC1024,
+ ACadVersion.AC1018,
+ };
+
+ // Characters AutoCAD does not allow in a layer name.
+ private static readonly char[] InvalidLayerCharacters = "<>/\\\":;?*|=,`".ToCharArray();
+
+ ///
+ /// Writes in the format its extension names: .svg, .dwg or
+ /// otherwise DXF. applies to DXF and DWG.
+ ///
+ public static void Export(
+ string path,
+ IEnumerable entities,
+ IEnumerable bends,
+ Units units,
+ ACadVersion version = ACadVersion.AC1032
+ )
+ {
+ var bendList = bends?.ToList() ?? new List();
+ var written = Written(entities, bendList);
+
+ if (Svg.IsSvg(path))
+ {
+ Svg.ExportEntities(written, bendList, path, units);
+ return;
+ }
+
+ var dwg = Path.GetExtension(path).Equals(".dwg", StringComparison.OrdinalIgnoreCase);
+ if (dwg && !DwgVersions.Contains(version))
+ throw new NotSupportedException($"DWG {version} cannot be written.");
+
+ var document = BuildDocument(written, bendList, units, version);
+ using var stream = File.Create(path);
+ if (dwg)
+ {
+ using var writer = new DwgWriter(stream, document);
+ writer.Write();
+ }
+ else
+ {
+ using var writer = new DxfWriter(stream, document, false);
+ writer.Write();
+ }
+ }
+
+ /// Builds the CAD document writes as DXF or DWG.
+ public static CadDocument BuildDocument(
+ IEnumerable entities,
+ IEnumerable bends,
+ Units units,
+ ACadVersion version = ACadVersion.AC1032
+ )
+ {
+ var bendList = bends?.ToList() ?? new List();
+ var document = new CadDocument(version);
+ document.Header.InsUnits =
+ units == Units.Millimeters ? UnitsType.Millimeters : UnitsType.Inches;
+
+ var layers = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ foreach (var entity in Written(entities, bendList))
+ Add(document, entity, LayerOf(document, layers, entity.Layer?.Name));
+
+ if (bendList.Count == 0)
+ return document;
+
+ var bendLayer = LayerOf(document, layers, BendLayerName);
+ var center = CenterLineType(document, units);
+ var height = BendNote.Height(units);
+
+ foreach (var bend in bendList)
+ {
+ document.Entities.Add(
+ new ACadSharp.Entities.Line
+ {
+ StartPoint = Xyz(bend.StartPoint),
+ EndPoint = Xyz(bend.EndPoint),
+ Layer = bendLayer,
+ LineType = center,
+ }
+ );
+
+ var note = BendNote.Text(bend);
+ if (note == null)
+ continue;
+
+ var (position, angle) = BendNote.Placement(bend, height);
+ document.Entities.Add(
+ new MText
+ {
+ InsertPoint = Xyz(position),
+ Value = IsUnicode(version) ? note : EscapeNonAscii(note),
+ Height = height,
+ // MText takes its rotation as the direction of its X axis.
+ AlignmentPoint = new XYZ(PortableMath.Cos(angle), PortableMath.Sin(angle), 0),
+ AttachmentPoint = AttachmentPointType.BottomCenter,
+ Layer = bendLayer,
+ }
+ );
+ }
+
+ return document;
+ }
+
+ // Rapids are not drawing geometry, and a line picked as a bend is written as that bend.
+ private static List Written(IEnumerable entities, List bends)
+ {
+ var bendSources = new HashSet(
+ bends.Where(b => b.SourceEntity != null).Select(b => b.SourceEntity)
+ );
+ return entities
+ .Where(e => e.Layer != SpecialLayers.Rapid && !bendSources.Contains(e))
+ .ToList();
+ }
+
+ private static void Add(CadDocument document, GeoEntity entity, AcadLayer layer)
+ {
+ switch (entity)
+ {
+ case Geometry.Line line:
+ document.Entities.Add(
+ new ACadSharp.Entities.Line
+ {
+ StartPoint = Xyz(line.StartPoint),
+ EndPoint = Xyz(line.EndPoint),
+ Layer = layer,
+ }
+ );
+ break;
+
+ case Geometry.Arc arc:
+ var startAngle = arc.StartAngle;
+ var endAngle = arc.EndAngle;
+ if (arc.IsReversed)
+ OpenNest.Math.Generic.Swap(ref startAngle, ref endAngle);
+ document.Entities.Add(
+ new ACadSharp.Entities.Arc
+ {
+ Center = Xyz(arc.Center),
+ Radius = arc.Radius,
+ StartAngle = startAngle,
+ EndAngle = endAngle,
+ Layer = layer,
+ }
+ );
+ break;
+
+ case Geometry.Circle circle:
+ document.Entities.Add(
+ new ACadSharp.Entities.Circle
+ {
+ Center = Xyz(circle.Center),
+ Radius = circle.Radius,
+ Layer = layer,
+ }
+ );
+ break;
+
+ case Geometry.Shape shape:
+ foreach (var child in shape.Entities)
+ Add(document, child, layer);
+ break;
+ }
+ }
+
+ private static AcadLayer LayerOf(
+ CadDocument document,
+ Dictionary layers,
+ string name
+ )
+ {
+ name = LayerName(name);
+ if (layers.TryGetValue(name, out var layer))
+ return layer;
+
+ if (!document.Layers.TryGetValue(name, out layer))
+ {
+ layer = new AcadLayer(name) { Color = LayerColor(name) };
+ document.Layers.Add(layer);
+ }
+
+ layers.Add(name, layer);
+ return layer;
+ }
+
+ private static string LayerName(string name)
+ {
+ if (string.IsNullOrWhiteSpace(name))
+ return AcadLayer.DefaultName;
+
+ var characters = name.Trim().ToCharArray();
+ for (var i = 0; i < characters.Length; i++)
+ {
+ if (Array.IndexOf(InvalidLayerCharacters, characters[i]) >= 0 || char.IsControl(characters[i]))
+ characters[i] = '_';
+ }
+ return new string(characters);
+ }
+
+ private static Color LayerColor(string name)
+ {
+ if (name.Equals(BendLayerName, StringComparison.OrdinalIgnoreCase))
+ return new Color(2);
+ if (name.Equals(Bend.EtchLayer.Name, StringComparison.OrdinalIgnoreCase))
+ return new Color(3);
+ if (name.Equals(SpecialLayers.Scribe.Name, StringComparison.OrdinalIgnoreCase))
+ return new Color(6);
+ return new Color(7);
+ }
+
+ // AutoCAD's CENTER pattern, scaled for millimeter drawings like its ISO linetypes.
+ private static LineType CenterLineType(CadDocument document, Units units)
+ {
+ const string name = "CENTER";
+ if (document.LineTypes.TryGetValue(name, out var existing))
+ return existing;
+
+ var scale = units == Units.Millimeters ? 25.4 : 1.0;
+ var lineType = new LineType(name) { Description = "Center ____ _ ____ _ ____" };
+ foreach (var length in new[] { 1.25, -0.25, 0.25, -0.25 })
+ lineType.AddSegment(new LineType.Segment { Length = length * scale });
+ document.LineTypes.Add(lineType);
+ return lineType;
+ }
+
+ // Files before 2007 are not Unicode, and ACadSharp reads their non-ASCII text back
+ // wrongly, so notes there use MText's \U+XXXX escapes, which the bend detector decodes.
+ private static bool IsUnicode(ACadVersion version) =>
+ version is ACadVersion.AC1021 or ACadVersion.AC1024 or ACadVersion.AC1027 or ACadVersion.AC1032;
+
+ private static string EscapeNonAscii(string text)
+ {
+ var escaped = new System.Text.StringBuilder(text.Length);
+ foreach (var character in text)
+ {
+ if (character < 128)
+ escaped.Append(character);
+ else
+ escaped.Append($"\\U+{(int)character:X4}");
+ }
+ return escaped.ToString();
+ }
+
+ private static XYZ Xyz(Vector point) => new XYZ(point.X, point.Y, 0);
+ }
+}
diff --git a/OpenNest.IO/CadImporter.cs b/OpenNest.IO/CadImporter.cs
index 57c5fcc0..35eb4934 100644
--- a/OpenNest.IO/CadImporter.cs
+++ b/OpenNest.IO/CadImporter.cs
@@ -48,7 +48,9 @@ namespace OpenNest.IO
}
var bends = new List();
- if (options.DetectBends && dxf.Document != null)
+ if (options.DetectBends && dxf.Bends != null)
+ bends = dxf.Bends;
+ else if (options.DetectBends && dxf.Document != null)
{
bends =
options.BendDetectorName == null
diff --git a/OpenNest.IO/DxfImportResult.cs b/OpenNest.IO/DxfImportResult.cs
index 43fb3f45..f3148132 100644
--- a/OpenNest.IO/DxfImportResult.cs
+++ b/OpenNest.IO/DxfImportResult.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using ACadSharp;
+using OpenNest.Bending;
using OpenNest.Geometry;
namespace OpenNest.IO
@@ -14,6 +15,12 @@ namespace OpenNest.IO
///
public List RawEntities { get; set; } = new();
public CadDocument Document { get; set; }
+
+ ///
+ /// Bends the file states outright, as an SVG's BEND layer does; null when bends are
+ /// detected from instead.
+ ///
+ public List Bends { get; set; }
public List Warnings { get; set; } = new();
}
}
diff --git a/OpenNest.IO/Svg.cs b/OpenNest.IO/Svg.cs
index 60b81da3..55489071 100644
--- a/OpenNest.IO/Svg.cs
+++ b/OpenNest.IO/Svg.cs
@@ -5,9 +5,11 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
+using OpenNest.Bending;
using OpenNest.CNC;
using OpenNest.Converters;
using OpenNest.Geometry;
+using OpenNest.IO.Bending;
using OpenNest.Math;
namespace OpenNest.IO
@@ -19,6 +21,10 @@ namespace OpenNest.IO
public static class Svg
{
internal const string PlateLayerName = "PLATE";
+ internal const string BendDirectionAttribute = "data-bend-direction";
+ internal const string BendAngleAttribute = "data-bend-angle";
+ internal const string BendRadiusAttribute = "data-bend-radius";
+ internal const string BendNoteAttribute = "data-bend-note";
private static readonly XNamespace Ns = "http://www.w3.org/2000/svg";
@@ -87,10 +93,36 @@ namespace OpenNest.IO
ExportEntities(entities, stream, units);
}
- public static void ExportEntities(IEnumerable entities, Stream stream, Units units)
+ public static void ExportEntities(IEnumerable entities, Stream stream, Units units) =>
+ ExportEntities(entities, null, stream, units);
+
+ ///
+ /// Writes entities as
+ /// does, plus each bend as a line in a BEND group whose data-bend-*
+ /// attributes import reads back, with its note as text for people.
+ ///
+ public static void ExportEntities(
+ IEnumerable entities,
+ IEnumerable bends,
+ string path,
+ Units units
+ )
+ {
+ using var stream = File.Create(path);
+ ExportEntities(entities, bends, stream, units);
+ }
+
+ public static void ExportEntities(
+ IEnumerable entities,
+ IEnumerable bends,
+ Stream stream,
+ Units units
+ )
{
var list = entities.ToList();
- var bounds = list.Count > 0 ? list.GetBoundingBox() : new Box(0, 0, 1, 1);
+ var bendList = bends?.ToList() ?? new List();
+ var extents = list.Concat(bendList.Select(b => (Entity)b.ToLine())).ToList();
+ var bounds = extents.Count > 0 ? extents.GetBoundingBox() : new Box(0, 0, 1, 1);
// Half of each stroke falls outside the outermost geometry; keep it on the page.
var margin = System.Math.Max(System.Math.Max(bounds.Length, bounds.Width), 1) * 0.01;
@@ -115,6 +147,9 @@ namespace OpenNest.IO
foreach (var layer in list.GroupBy(e => e.Layer?.Name ?? Layer.Default.Name))
root.Add(LayerGroup(layer.Key, layer.ToList()));
+ if (bendList.Count > 0)
+ root.Add(BendGroup(bendList, units));
+
new XDocument(new XDeclaration("1.0", "utf-8", null), root).Save(stream);
}
@@ -167,6 +202,66 @@ namespace OpenNest.IO
return group;
}
+ private static XElement BendGroup(List bends, Units units)
+ {
+ const string color = "#c0a000";
+ var group = new XElement(
+ Ns + "g",
+ new XAttribute("data-layer", CadExporter.BendLayerName),
+ new XAttribute("stroke", color)
+ );
+ var height = BendNote.Height(units);
+
+ foreach (var bend in bends)
+ {
+ var line = new XElement(
+ Ns + "line",
+ new XAttribute("x1", Number(bend.StartPoint.X)),
+ new XAttribute("y1", Number(-bend.StartPoint.Y)),
+ new XAttribute("x2", Number(bend.EndPoint.X)),
+ new XAttribute("y2", Number(-bend.EndPoint.Y)),
+ new XAttribute("stroke-width", "1"),
+ new XAttribute("stroke-dasharray", "12 3 3 3"),
+ new XAttribute("vector-effect", "non-scaling-stroke")
+ );
+ if (bend.Direction != BendDirection.Unknown)
+ line.Add(new XAttribute(BendDirectionAttribute, bend.Direction.ToString().ToLowerInvariant()));
+ if (bend.Angle.HasValue)
+ line.Add(new XAttribute(BendAngleAttribute, Number(bend.Angle.Value)));
+ if (bend.Radius.HasValue)
+ line.Add(new XAttribute(BendRadiusAttribute, Number(bend.Radius.Value)));
+
+ var note = BendNote.Text(bend);
+ if (!string.IsNullOrWhiteSpace(bend.NoteText))
+ line.Add(new XAttribute(BendNoteAttribute, bend.NoteText));
+ group.Add(line);
+
+ if (note == null)
+ continue;
+
+ // SVG's Y points down, so the note's turn is the other way round.
+ var (position, angle) = BendNote.Placement(bend, height);
+ var x = Number(position.X);
+ var y = Number(-position.Y);
+ group.Add(
+ new XElement(
+ Ns + "text",
+ new XAttribute("x", x),
+ new XAttribute("y", y),
+ new XAttribute("font-size", Number(height)),
+ new XAttribute("font-family", "sans-serif"),
+ new XAttribute("text-anchor", "middle"),
+ new XAttribute("fill", color),
+ new XAttribute("stroke", "none"),
+ new XAttribute("transform", $"rotate({Number(-Angle.ToDegrees(angle))} {x} {y})"),
+ note
+ )
+ );
+ }
+
+ return group;
+ }
+
private static void MoveTo(StringBuilder data, Vector point, ref Vector position)
{
if (!position.IsValid() || position.DistanceTo(point) >= Tolerance.Epsilon)
diff --git a/OpenNest.IO/SvgReader.cs b/OpenNest.IO/SvgReader.cs
index fc88d65d..edf078c8 100644
--- a/OpenNest.IO/SvgReader.cs
+++ b/OpenNest.IO/SvgReader.cs
@@ -8,6 +8,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
+using OpenNest.Bending;
using OpenNest.Geometry;
using OpenNest.Math;
@@ -56,6 +57,7 @@ namespace OpenNest.IO
private readonly List lines = new List();
private readonly List arcs = new List();
private readonly List circles = new List();
+ private readonly List bends = new List();
private readonly HashSet activeUses = new HashSet();
private SvgReader(XElement root, double tolerance)
@@ -241,6 +243,7 @@ namespace OpenNest.IO
{
Entities = entities,
RawEntities = raw,
+ Bends = bends,
Warnings = skipped
.OrderBy(s => s.Key, StringComparer.Ordinal)
.Select(s => $"Skipped {s.Value} <{s.Key}> element(s); convert them to paths to import them.")
@@ -270,7 +273,9 @@ namespace OpenNest.IO
case "a":
case "switch":
var layer = LayerOf(element, parentLayer);
- if (!IsSkippedLayer(layer.Name))
+ if (IsBendLayer(layer.Name))
+ ReadBends(element, transform);
+ else if (!IsSkippedLayer(layer.Name))
WalkChildren(element, transform, layer);
break;
@@ -356,6 +361,70 @@ namespace OpenNest.IO
|| string.Equals(name, SpecialLayers.Rapid.Name, StringComparison.OrdinalIgnoreCase)
|| string.Equals(name, Svg.PlateLayerName, StringComparison.OrdinalIgnoreCase);
+ private static bool IsBendLayer(string name) =>
+ string.Equals(name, CadExporter.BendLayerName, StringComparison.OrdinalIgnoreCase);
+
+ ///
+ /// Every line on a BEND layer is a bend, as a center line on a DXF's BEND layer
+ /// is; OpenNest's export adds its direction, angle, radius and note as
+ /// data-bend-* attributes. Other shapes and text there are only for people.
+ ///
+ private void ReadBends(XElement group, SvgTransform transform)
+ {
+ foreach (var child in group.Elements())
+ {
+ if (child.Name.Namespace != svgNamespace || IsHidden(child))
+ continue;
+
+ var placed = transform.Then(SvgTransform.Parse(child.Attribute("transform")?.Value));
+ if (child.Name.LocalName == "g")
+ {
+ ReadBends(child, placed);
+ continue;
+ }
+
+ if (child.Name.LocalName != "line" || HasRelativeSize(child, "x1", "y1", "x2", "y2"))
+ continue;
+
+ var start = placed.Apply(new Vector(Measure(child, "x1") ?? 0, Measure(child, "y1") ?? 0));
+ var end = placed.Apply(new Vector(Measure(child, "x2") ?? 0, Measure(child, "y2") ?? 0));
+ if (start.DistanceTo(end) < Tolerance.Epsilon)
+ continue;
+
+ var direction = Enum.TryParse(
+ child.Attribute(Svg.BendDirectionAttribute)?.Value,
+ ignoreCase: true,
+ out var parsed
+ ) && Enum.IsDefined(parsed)
+ ? parsed
+ : BendDirection.Unknown;
+ var radius = Number(child, Svg.BendRadiusAttribute);
+
+ bends.Add(
+ new Bend
+ {
+ StartPoint = start,
+ EndPoint = end,
+ Direction = direction,
+ Angle = Number(child, Svg.BendAngleAttribute),
+ // The radius is a length in the file's units, like the line.
+ Radius = radius * placed.ScaleFactor,
+ NoteText = child.Attribute(Svg.BendNoteAttribute)?.Value,
+ }
+ );
+ }
+ }
+
+ private static double? Number(XElement element, string attribute) =>
+ double.TryParse(
+ element.Attribute(attribute)?.Value,
+ NumberStyles.Float,
+ CultureInfo.InvariantCulture,
+ out var value
+ ) && double.IsFinite(value)
+ ? value
+ : null;
+
private void WalkUse(XElement use, SvgTransform transform, Layer layer)
{
var href = use.Attributes().FirstOrDefault(a => a.Name.LocalName == "href")?.Value;
diff --git a/OpenNest.Tests/IO/CadExportRoundTripTests.cs b/OpenNest.Tests/IO/CadExportRoundTripTests.cs
new file mode 100644
index 00000000..a7ddb0c9
--- /dev/null
+++ b/OpenNest.Tests/IO/CadExportRoundTripTests.cs
@@ -0,0 +1,231 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Xml.Linq;
+using ACadSharp;
+using OpenNest.Bending;
+using OpenNest.Geometry;
+using OpenNest.IO;
+using Xunit;
+
+namespace OpenNest.Tests.IO
+{
+ public class CadExportRoundTripTests : IDisposable
+ {
+ private readonly string folder = Directory.CreateTempSubdirectory("cad-export-tests").FullName;
+
+ public void Dispose() => Directory.Delete(folder, true);
+
+ public static IEnumerable