diff --git a/EtchBendLines/Extensions.cs b/EtchBendLines/Extensions.cs index 1344609..50ad9d9 100644 --- a/EtchBendLines/Extensions.cs +++ b/EtchBendLines/Extensions.cs @@ -13,6 +13,11 @@ namespace EtchBendLines return new Vector2(pt.X, pt.Y); } + public static bool IsEqualTo(this Vector3 pt, Vector3 pt1) + { + return pt.X.IsEqualTo(pt1.X) && pt.Y.IsEqualTo(pt1.Y) && pt.Z.IsEqualTo(pt1.Z); + } + public static bool IsVertical(this Line line) { return line.StartPoint.X == line.EndPoint.X; diff --git a/EtchBendLines/Program.cs b/EtchBendLines/Program.cs index 73f11f3..8dc3f30 100644 --- a/EtchBendLines/Program.cs +++ b/EtchBendLines/Program.cs @@ -98,7 +98,20 @@ namespace EtchBendLines foreach (var bendline in upBends) { var etchLines = bendline.GetEtchLines(ETCH_LENGTH); - dxf.AddEntity(etchLines); + + foreach (var etchLine in etchLines) + { + var existing = dxf.Lines.FirstOrDefault(l => l.StartPoint.IsEqualTo(etchLine.StartPoint)); + + if (existing != null) + { + // ensure the layer is correct and skip adding the etch line since it already exists. + existing.Layer = etchLine.Layer; + continue; + } + + dxf.AddEntity(etchLine); + } } dxf.Save(filePath);