Don't add duplicate etch lines.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user