Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment_Engine: assign construction by type #2010

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Environment_Engine/Environment_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<Compile Include="Modify\RemovePanels.cs" />
<Compile Include="Modify\SetAdjacentSpaces.cs" />
<Compile Include="Modify\SetFloorPanels.cs" />
<Compile Include="Modify\SetPanelConstructionByType.cs" />
<Compile Include="Modify\SetOpeningConstruction.cs" />
<Compile Include="Modify\SetOpeningType.cs" />
<Compile Include="Modify\SetPanelTypeByAdjacencies.cs" />
Expand Down
70 changes: 70 additions & 0 deletions Environment_Engine/Modify/SetPanelConstructionByType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2020, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Geometry;
using BH.oM.Environment.Elements;
using BH.oM.Environment;
using BH.oM.Geometry;

using BH.oM.Physical.Constructions;

using System.Collections.Generic;
using System.Linq;
using BH.oM.Environment.Fragments;

using BH.oM.Reflection.Attributes;
using System.ComponentModel;

using BH.Engine.Base;
using System;
using BH.oM.Physical.Elements;

namespace BH.Engine.Environment
{
public static partial class Modify
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Update a panel construction based on the panel type")]
[Input("panels", "A collection of Environment Panels to update the constructions of")]
[Input("newConstruction", "The new construction to assign to the panels")]
[Input("panelType", "The type of the panels to update")]
[Output("panels", "The collection of Environment Panels with updated constructions")]
public static List<Panel> SetPanelConstructionByType(this List<Panel> panels, IConstruction newConstruction, PanelType panelType)
linaeriksson marked this conversation as resolved.
Show resolved Hide resolved
{
List<Panel> clones = new List<Panel>(panels.Select(x => x.DeepClone<Panel>()).ToList());

foreach (Panel clone in clones)
linaeriksson marked this conversation as resolved.
Show resolved Hide resolved
{
if (clone.Type == panelType)
{
clone.Construction = newConstruction;
}
}

return clones;
linaeriksson marked this conversation as resolved.
Show resolved Hide resolved
}
}
}