Skip to content

Commit

Permalink
Add UniqueConstructions for Openings #1690
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser Greenroyd committed Apr 22, 2020
1 parent 3c5c26e commit ada9461
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions Environment_Engine/Query/UniqueConstructions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,34 @@ public static List<Construction> UniqueConstructions(this List<Panel> panels, bo
unique.Add(be.Construction as Construction);
}

foreach (Opening o in be.Openings)
unique.AddRange(be.Openings.UniqueConstructions());
}

return unique;
}

[Description("Returns a collection of unique constructions from a collection of Environment Openings")]
[Input("openings", "A collection of Environment Openings")]
[Input("includeConstructionName", "Flag to determine whether or not to use the construction name as a parameter of uniqueness. Default false")]
[Output("uniqueConstructions", "A collection of unique Construction objects")]
public static List<Construction> UniqueConstructions(this List<Opening> openings, bool includeConstructionName = false)
{
List<Construction> unique = new List<Construction>();

foreach (Opening o in openings)
{
if (o.FrameConstruction != null)
{
Construction t1 = unique.Where(x => x.UniqueConstructionName(includeConstructionName) == o.FrameConstruction.UniqueConstructionName(includeConstructionName)).FirstOrDefault();
if (t1 == null)
unique.Add(o.FrameConstruction as Construction);
}

if (o.OpeningConstruction != null)
{
if (o.FrameConstruction != null)
{
Construction t2 = unique.Where(x => x.UniqueConstructionName(includeConstructionName) == o.FrameConstruction.UniqueConstructionName(includeConstructionName)).FirstOrDefault();
if (t2 == null)
unique.Add(o.FrameConstruction as Construction);
}

if (o.OpeningConstruction != null)
{
Construction t3 = unique.Where(x => x.UniqueConstructionName(includeConstructionName) == o.OpeningConstruction.UniqueConstructionName(includeConstructionName)).FirstOrDefault();
if (t3 == null)
unique.Add(o.OpeningConstruction as Construction);
}
Construction t2 = unique.Where(x => x.UniqueConstructionName(includeConstructionName) == o.OpeningConstruction.UniqueConstructionName(includeConstructionName)).FirstOrDefault();
if (t2 == null)
unique.Add(o.OpeningConstruction as Construction);
}
}

Expand Down

0 comments on commit ada9461

Please sign in to comment.