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

GetRevitElementType and GetRevitTypeParameterValue methods added #1166

Merged
merged 2 commits into from
Jan 28, 2022
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
204 changes: 204 additions & 0 deletions Revit_Engine/Query/GetRevitElementType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2022, 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.oM.Adapters.Revit.Elements;
using BH.oM.Architecture.Elements;
using BH.oM.Base;
using BH.oM.Base.Attributes;
using BH.oM.Physical.Elements;
using System.ComponentModel;

namespace BH.Engine.Adapters.Revit
{
public static partial class Query
{
/***************************************************/
/**** Public methods ****/
/***************************************************/

[Description("Extracts Revit element type representation from a given BHoM object pulled from Revit.")]
[Input("bHoMObject", "BHoMObject to be queried for Revit element type representation.")]
[Output("elementType", "Revit element type representation extracted from the input BHoM object pulled from Revit.")]
public static IBHoMObject IGetRevitElementType(this IBHoMObject bHoMObject)
{
if (bHoMObject == null)
{
BH.Engine.Base.Compute.RecordError("Could not extract Revit element type representation from a null BHoM object.");
return null;
}

return (GetRevitElementType(bHoMObject as dynamic));
}


/***************************************************/
/**** Private methods ****/
/***************************************************/

private static IBHoMObject GetRevitElementType(this Ceiling bHoMObject)
{
return bHoMObject.Construction;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.Architecture.BuildersWork.Opening bHoMObject)
{
return bHoMObject.Profile;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.Environment.Elements.Panel bHoMObject)
{
return bHoMObject.Construction;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.Facade.Elements.FrameEdge bHoMObject)
{
return bHoMObject.FrameEdgeProperty;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.Facade.Elements.Opening bHoMObject)
{
return bHoMObject.OpeningConstruction;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.Facade.Elements.Panel bHoMObject)
{
return bHoMObject.Construction;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.MEP.System.CableTray bHoMObject)
{
return bHoMObject.SectionProperty;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.MEP.System.Duct bHoMObject)
{
return bHoMObject.SectionProperty;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.MEP.System.Pipe bHoMObject)
{
return bHoMObject.SectionProperty;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this IFramingElement bHoMObject)
{
return bHoMObject.Property;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this Door bHoMObject)
{
return bHoMObject.Construction;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this ISurface bHoMObject)
{
return bHoMObject.Construction;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this Window bHoMObject)
{
return bHoMObject.Construction;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this IInstance bHoMObject)
{
return bHoMObject.Properties;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this Sheet bHoMObject)
{
return bHoMObject.InstanceProperties;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this Viewport bHoMObject)
{
return bHoMObject.InstanceProperties;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this ViewPlan bHoMObject)
{
return bHoMObject.InstanceProperties;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.Structure.Elements.Bar bHoMObject)
{
return bHoMObject.SectionProperty;
}

/***************************************************/

private static IBHoMObject GetRevitElementType(this BH.oM.Structure.Elements.Panel bHoMObject)
{
return bHoMObject.Property;
}


/***************************************************/
/**** Fallback methods ****/
/***************************************************/

private static IBHoMObject GetRevitElementType(this IBHoMObject bHoMObject)
{
BH.Engine.Base.Compute.RecordError($"BHoM object of type {bHoMObject.GetType().FullName} does not store the information about correspondent Revit element type.");
return null;
}

/***************************************************/
}
}



58 changes: 58 additions & 0 deletions Revit_Engine/Query/GetRevitTypeParameterValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2022, 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.oM.Adapters.Revit.Parameters;
using BH.oM.Base;
using BH.oM.Base.Attributes;
using System.ComponentModel;
using System.Linq;
using System.Collections.Generic;

namespace BH.Engine.Adapters.Revit
{
public static partial class Query
{
/***************************************************/
/**** Public methods ****/
/***************************************************/

[Description("Retrieves value of a parameter from a Revit element type representation attached to a BHoM object pulled from Revit.")]
[Input("bHoMObject", "BHoMObject to which the parameters will be attached.")]
[Input("parameterName", "Name of the parameter to be sought for.")]
[Output("value")]
public static object GetRevitTypeParameterValue(this IBHoMObject bHoMObject, string parameterName)
{
if (bHoMObject == null)
{
BH.Engine.Base.Compute.RecordError("Could not extract Revit element type parameter value from a null BHoM object.");
return null;
}

return bHoMObject.IGetRevitElementType()?.GetRevitParameterValue(parameterName);
}

/***************************************************/
}
}



21 changes: 19 additions & 2 deletions Revit_Engine/Revit_Engine.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -95,6 +95,11 @@
<HintPath>C:\ProgramData\BHoM\Assemblies\Environment_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Facade_oM">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\Facade_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Geometry_Engine">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\Geometry_Engine.dll</HintPath>
Expand All @@ -115,6 +120,11 @@
<HintPath>C:\ProgramData\BHoM\Assemblies\Library_Engine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MEP_oM">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\MEP_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Physical_Engine">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\Physical_Engine.dll</HintPath>
Expand All @@ -130,6 +140,11 @@
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Spatial_oM">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\Spatial_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Structure_oM">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\Structure_oM.dll</HintPath>
Expand Down Expand Up @@ -189,6 +204,8 @@
<Compile Include="Modify\SetTag.cs" />
<Compile Include="Modify\Move.cs" />
<Compile Include="Modify\Transform.cs" />
<Compile Include="Query\GetRevitElementType.cs" />
<Compile Include="Query\GetRevitTypeParameterValue.cs" />
<Compile Include="Query\HashString.cs" />
<Compile Include="Query\ComparisonInclusion.cs" />
<Compile Include="Query\FilterDescription.cs" />
Expand Down Expand Up @@ -252,4 +269,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>