Don't add duplicate etch lines.

This commit is contained in:
AJ
2019-09-07 07:57:44 -04:00
parent 1661aa42dd
commit be50441475
2 changed files with 19 additions and 1 deletions

View File

@@ -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;

View File

@@ -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);