Skip to content
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
70 changes: 70 additions & 0 deletions Revit_Core_Engine/Convert/Physical/FromRevit/PadFoundation.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 - 2026, 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 Autodesk.Revit.DB;
using BH.Engine.Adapters.Revit;
using BH.oM.Adapters.Revit.Settings;
using BH.oM.Base;
using BH.oM.Base.Attributes;
using BH.oM.Geometry;
using BH.oM.Physical.Elements;
using System.Collections.Generic;
using System.ComponentModel;

namespace BH.Revit.Engine.Core
{
public static partial class Convert
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Converts a Revit FamilyInstance to BH.oM.Physical.Elements.PadFoundation.")]
[Input("familyInstance", "Revit FamilyInstance to be converted.")]
[Input("settings", "Revit adapter settings to be used while performing the convert.")]
[Input("refObjects", "Optional, a collection of objects already processed in the current adapter action, stored to avoid processing the same object more than once.")]
[Output("padFoundation", "BH.oM.Physical.Elements.PadFoundation resulting from converting the input Revit FamilyInstance.")]
public static PadFoundation PadFoundationFromRevit(this FamilyInstance familyInstance, RevitSettings settings = null, Dictionary<string, List<IBHoMObject>> refObjects = null)
{
settings = settings.DefaultIfNull();

PadFoundation padFoundation = refObjects.GetValue<PadFoundation>(familyInstance.Id);
if (padFoundation != null)
return padFoundation;

PlanarSurface location = familyInstance.LocationSurfacePadFoundation(settings);

oM.Physical.Constructions.Construction construction = familyInstance.ConstructionPadFoundation(settings, refObjects);
padFoundation = BH.Engine.Physical.Create.PadFoundation(location, construction, familyInstance.FamilyTypeFullName());

//Set identifiers, parameters & custom data
padFoundation.SetIdentifiers(familyInstance);
padFoundation.CopyParameters(familyInstance, settings.MappingSettings);
padFoundation.SetProperties(familyInstance, settings.MappingSettings);

refObjects.AddOrReplace(familyInstance.Id, padFoundation);
return padFoundation;
}

/***************************************************/
}
}
1 change: 1 addition & 0 deletions Revit_Core_Engine/Modify/SetLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

using Autodesk.Revit.DB;
using BH.Engine.Geometry;
using BH.Engine.Spatial;
using BH.oM.Adapters.Revit.Elements;
using BH.oM.Adapters.Revit.Settings;
using BH.oM.Base;
Expand Down
3 changes: 1 addition & 2 deletions Revit_Core_Engine/Query/BHoMType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ public static Type BHoMType(this FamilyInstance familyInstance, Discipline disci
double width = Math.Max(bbox.Max.X - bbox.Min.X, bbox.Max.Y - bbox.Min.Y);
double height = bbox.Max.Z - bbox.Min.Z;
if (height < width)
//return typeof(BH.oM.Physical.Elements.PadFoundation);
return null; // Temporarily disabled until PadFoundation is properly implemented in the Revit adapter.
return typeof(BH.oM.Physical.Elements.PadFoundation);
else if (familyInstance.GetSubComponentIds().Count != 0)
//return typeof(BH.oM.Physical.Elements.PileFoundation);
return null; // Temporarily disabled until PileFoundation is properly implemented in the Revit adapter.
Expand Down
6 changes: 6 additions & 0 deletions Revit_Core_Engine/Query/BuiltInCategories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public static HashSet<BuiltInCategory> BuiltInCategories(this Type bHoMType)
Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFoundation
}
},
{
typeof (BH.oM.Physical.Elements.PadFoundation), new BuiltInCategory[]
{
Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFoundation,
}
},
{
typeof (Column), new BuiltInCategory[]
{
Expand Down
52 changes: 51 additions & 1 deletion Revit_Core_Engine/Query/Construction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Analysis;
using BH.Engine.Adapters.Revit;
using BH.Engine.Base;
using BH.oM.Adapters.Revit.Settings;
using BH.oM.Environment.MaterialFragments;
using BH.oM.Base;
using BH.oM.Base.Attributes;
using BH.oM.Environment.MaterialFragments;
using System.Collections.Generic;
using System.ComponentModel;

namespace BH.Revit.Engine.Core
Expand Down Expand Up @@ -56,6 +60,52 @@
return construction;
}

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

[Description("Extracts the construction of the given Revit FamilyInstance.")]
[Input("familyInstance", "Revit FamilyInstance to extract the construction from.")]
[Input("settings", "Revit adapter settings to be used while performing the query.")]
[Output("construction", "Construction of the input Revit FamilyInstance.")]
public static oM.Physical.Constructions.Construction Construction(this FamilyInstance familyInstance, RevitSettings settings = null, Dictionary<string, List<IBHoMObject>> refObjects = null)

Check warning on line 69 in Revit_Core_Engine/Query/Construction.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Revit_Core_Engine/Query/Construction.cs#L69

Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent
{
if (familyInstance == null)
return null;

if (familyInstance.Category.Id.Value() == (int)Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFoundation)
return familyInstance.ConstructionPadFoundation(settings, refObjects);
else
return familyInstance.Symbol.ConstructionFromRevit(settings, refObjects);
}

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

[Description("Extracts the construction of the given Revit pad foundation.")]
[Input("familyInstance", "Revit pad foundation to extract the construction from.")]
[Input("settings", "Revit adapter settings to be used while performing the query.")]
[Output("construction", "Construction of the input Revit pad foundation.")]
public static oM.Physical.Constructions.Construction ConstructionPadFoundation(this FamilyInstance familyInstance, RevitSettings settings = null, Dictionary<string, List<IBHoMObject>> refObjects = null)

Check warning on line 86 in Revit_Core_Engine/Query/Construction.cs

View check run for this annotation

BHoMBot-CI / documentation-compliance

Revit_Core_Engine/Query/Construction.cs#L86

Input parameter requires a matching Input attribute - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsInputAttributePresent
{
settings = settings.DefaultIfNull();

FamilySymbol familySymbol = familyInstance?.Symbol;
if (familySymbol == null)
return null;

oM.Physical.Constructions.Construction construction = refObjects.GetValue<oM.Physical.Constructions.Construction>(familyInstance.Id);
if (construction != null)
return construction;

construction = familySymbol.ConstructionFromRevit(settings, refObjects);
construction = construction.DeepClone();

BoundingBoxXYZ bbox = familyInstance.get_BoundingBox(null);
double thickness = (bbox.Max.Z - bbox.Min.Z).ToSI(SpecTypeId.Length);

BH.oM.Physical.Materials.Material material = familyInstance.StructuralMaterial(settings, refObjects);
construction.Layers.Add(new oM.Physical.Constructions.Layer { Name = construction.Name, Material = material, Thickness = thickness });
return construction;
}


/***************************************************/
/**** Private methods ****/
Expand Down
4 changes: 2 additions & 2 deletions Revit_Core_Engine/Query/FramingElementProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static IFramingElementProperty FramingElementProperty(this FamilyInstance
return framingProperty;

// Convert the material to BHoM
BH.oM.Physical.Materials.Material material = familyInstance.FramingMaterial(settings, refObjects);
BH.oM.Physical.Materials.Material material = familyInstance.StructuralMaterial(settings, refObjects);

// Convert the profile to BHoM and mirror it if needed
IProfile profile = familyInstance.Symbol.ProfileFromRevit(settings, refObjects);
Expand Down Expand Up @@ -111,7 +111,7 @@ public static IFramingElementProperty PileFramingElementProperty(this FamilyInst
return framingProperty;

// Convert the material to BHoM
BH.oM.Physical.Materials.Material material = familyInstance.FramingMaterial(settings, refObjects);
BH.oM.Physical.Materials.Material material = familyInstance.StructuralMaterial(settings, refObjects);

IProfile profile = familyInstance.Symbol.ProfileFromRevit(settings, refObjects);

Expand Down
70 changes: 70 additions & 0 deletions Revit_Core_Engine/Query/LocationSurface.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 - 2026, 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 Autodesk.Revit.DB;
using BH.Engine.Adapters.Revit;
using BH.oM.Adapters.Revit.Settings;
using BH.oM.Base.Attributes;
using BH.oM.Geometry;
using System;
using System.Collections.Generic;
using System.ComponentModel;

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

[Description("Queries a Revit pad foundation to find its location surface.")]
[Input("padFoundation", "Revit pad foundation to be queried.")]
[Input("settings", "Optional, settings to be used when extracting the location surface.")]
[Output("locationSurface", "BHoM location surface queried from the input pad foundation.")]
public static PlanarSurface LocationSurfacePadFoundation(this FamilyInstance padFoundation, RevitSettings settings)
{
settings = settings.DefaultIfNull();

List<PlanarFace> topFaces = new List<PlanarFace>();
foreach (Autodesk.Revit.DB.Face f in padFoundation.Faces(new Options(), settings))
{
PlanarFace pf = f as PlanarFace;
if (pf == null)
continue;

if (Math.Abs(1 - pf.FaceNormal.DotProduct(XYZ.BasisZ)) <= BH.oM.Adapters.Revit.Tolerance.Angle)
topFaces.Add(pf);
}

if (topFaces.Count == 1)
return topFaces[0].FromRevit();
else
{
BH.Engine.Base.Compute.RecordError($"Failed to extract geometry from pad foundation. ElementId: {padFoundation.Id.Value()}");
return null;
}

/***************************************************/
}
}
}
2 changes: 1 addition & 1 deletion Revit_Core_Engine/Query/MullionElementProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static FrameEdgeProperty MullionElementProperty(this Mullion mullion, Rev
return frameEdgeProperty;

// Convert the material to BHoM
BH.oM.Physical.Materials.Material material = mullion.FramingMaterial(settings, refObjects);
BH.oM.Physical.Materials.Material material = mullion.StructuralMaterial(settings, refObjects);

// Convert the profile to BHoM
IProfile profile = mullion.MullionType.ProfileFromRevit(settings, refObjects);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ public static partial class Query
/**** Public methods ****/
/***************************************************/

[PreviousVersion("9.1", "BH.Revit.Engine.Core.Query.FramingMaterial(Autodesk.Revit.DB.FamilyInstance, BH.oM.Adapters.Revit.Settings.RevitSettings, System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.List<BH.oM.Base.IBHoMObject>>)")]
[Description("Extracts a BHoM representation of material from Revit FamilyInstance representing a framing element.")]
[Input("familyInstance", "Revit FamilyInstance to be queried.")]
[Input("settings", "Revit adapter settings to be used while performing the query.")]
[Input("refObjects", "Optional, a collection of objects already processed in the current adapter action, stored to avoid processing the same object more than once.")]
[Output("material", "BHoM representation of material extracted from Revit FamilyInstance representing a framing element.")]
public static BH.oM.Physical.Materials.Material FramingMaterial(this FamilyInstance familyInstance, RevitSettings settings, Dictionary<string, List<IBHoMObject>> refObjects = null)
public static BH.oM.Physical.Materials.Material StructuralMaterial(this FamilyInstance familyInstance, RevitSettings settings, Dictionary<string, List<IBHoMObject>> refObjects = null)
{
settings = settings.DefaultIfNull();

Expand Down