diff --git a/Revit_Engine/Query/GetRevitElementType.cs b/Revit_Engine/Query/GetRevitElementType.cs new file mode 100644 index 000000000..9c58a7792 --- /dev/null +++ b/Revit_Engine/Query/GetRevitElementType.cs @@ -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 . + */ + +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; + } + + /***************************************************/ + } +} + + + diff --git a/Revit_Engine/Query/GetRevitTypeParameterValue.cs b/Revit_Engine/Query/GetRevitTypeParameterValue.cs new file mode 100644 index 000000000..c0b0e2773 --- /dev/null +++ b/Revit_Engine/Query/GetRevitTypeParameterValue.cs @@ -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 . + */ + +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); + } + + /***************************************************/ + } +} + + + diff --git a/Revit_Engine/Revit_Engine.csproj b/Revit_Engine/Revit_Engine.csproj index daab665de..c30609808 100644 --- a/Revit_Engine/Revit_Engine.csproj +++ b/Revit_Engine/Revit_Engine.csproj @@ -1,4 +1,4 @@ - + @@ -95,6 +95,11 @@ C:\ProgramData\BHoM\Assemblies\Environment_oM.dll False + + False + C:\ProgramData\BHoM\Assemblies\Facade_oM.dll + False + False C:\ProgramData\BHoM\Assemblies\Geometry_Engine.dll @@ -115,6 +120,11 @@ C:\ProgramData\BHoM\Assemblies\Library_Engine.dll False + + False + C:\ProgramData\BHoM\Assemblies\MEP_oM.dll + False + False C:\ProgramData\BHoM\Assemblies\Physical_Engine.dll @@ -130,6 +140,11 @@ False False + + False + C:\ProgramData\BHoM\Assemblies\Spatial_oM.dll + False + False C:\ProgramData\BHoM\Assemblies\Structure_oM.dll @@ -189,6 +204,8 @@ + + @@ -252,4 +269,4 @@ --> - + \ No newline at end of file