diff --git a/Objects/Converters/ConverterRevit/ConverterRevit2020/ConverterRevit2020.csproj b/Objects/Converters/ConverterRevit/ConverterRevit2020/ConverterRevit2020.csproj index 079b2cede5..683bba2d88 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevit2020/ConverterRevit2020.csproj +++ b/Objects/Converters/ConverterRevit/ConverterRevit2020/ConverterRevit2020.csproj @@ -15,6 +15,7 @@ + diff --git a/Objects/Converters/ConverterRevit/ConverterRevit2021/ConverterRevit2021.csproj b/Objects/Converters/ConverterRevit/ConverterRevit2021/ConverterRevit2021.csproj index 94ed5663b1..d021bf9069 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevit2021/ConverterRevit2021.csproj +++ b/Objects/Converters/ConverterRevit/ConverterRevit2021/ConverterRevit2021.csproj @@ -15,6 +15,7 @@ + diff --git a/Objects/Converters/ConverterRevit/ConverterRevit2022/ConverterRevit2022.csproj b/Objects/Converters/ConverterRevit/ConverterRevit2022/ConverterRevit2022.csproj index 83a336eb6a..da03355564 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevit2022/ConverterRevit2022.csproj +++ b/Objects/Converters/ConverterRevit/ConverterRevit2022/ConverterRevit2022.csproj @@ -22,7 +22,8 @@ - + + diff --git a/Objects/Converters/ConverterRevit/ConverterRevit2023/ConverterRevit2023.csproj b/Objects/Converters/ConverterRevit/ConverterRevit2023/ConverterRevit2023.csproj index 0feaf53d85..7c8853756e 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevit2023/ConverterRevit2023.csproj +++ b/Objects/Converters/ConverterRevit/ConverterRevit2023/ConverterRevit2023.csproj @@ -21,7 +21,8 @@ - + + diff --git a/Objects/Converters/ConverterRevit/ConverterRevit2024/ConverterRevit2024.csproj b/Objects/Converters/ConverterRevit/ConverterRevit2024/ConverterRevit2024.csproj index 750b75222b..70da0de71f 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevit2024/ConverterRevit2024.csproj +++ b/Objects/Converters/ConverterRevit/ConverterRevit2024/ConverterRevit2024.csproj @@ -14,6 +14,7 @@ + diff --git a/Objects/Converters/ConverterRevit/ConverterRevit2025/ConverterRevit2025.csproj b/Objects/Converters/ConverterRevit/ConverterRevit2025/ConverterRevit2025.csproj index daf2872ec2..5dfe140713 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevit2025/ConverterRevit2025.csproj +++ b/Objects/Converters/ConverterRevit/ConverterRevit2025/ConverterRevit2025.csproj @@ -15,6 +15,7 @@ + diff --git a/Objects/Converters/ConverterRevit/ConverterRevitShared/ConversionUtils.cs b/Objects/Converters/ConverterRevit/ConverterRevitShared/ConversionUtils.cs index 307cca0e29..59c2e003fe 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevitShared/ConversionUtils.cs +++ b/Objects/Converters/ConverterRevit/ConverterRevitShared/ConversionUtils.cs @@ -17,6 +17,7 @@ using Speckle.Core.Models; using Speckle.Core.Models.Extensions; using DB = Autodesk.Revit.DB; +using IFC = Autodesk.Revit.DB.IFC; using Level = Objects.BuiltElements.Level; using Line = Objects.Geometry.Line; using Parameter = Objects.BuiltElements.Revit.Parameter; @@ -144,6 +145,31 @@ out List notes status: ApplicationObject.State.Created, logItem: $"Attached as hosted element to {host.UniqueId}" ); + + if (host is DB.Wall wall) + { + double area = GetAreaOfHostedElement(element as DB.FamilyInstance, wall); +#if REVIT2020 + double areaTransformed = UnitUtils.ConvertFromInternalUnits(area, DisplayUnitType.DUT_SQUARE_METERS); +#else + double areaTransformed = UnitUtils.ConvertFromInternalUnits(area, UnitTypeId.SquareMeters); +#endif + var paramObject = obj["parameters"]; + if (paramObject != null) + { + Base parameters = (Base)paramObject; + if (parameters != null) + { + var hostedAreaParameter = new Parameter( + "Cutout Area", + areaTransformed, + Speckle.Core.Kits.Units.Meters + ); // POC: it's always in meters, even if project units are something else + parameters["Cutout Area"] = hostedAreaParameter; + } + } + } + convertedHostedElements.Add(obj); ConvertedObjects.Add(obj.applicationId); } @@ -1108,6 +1134,27 @@ public WallLocationLine GetWallLocationLine(LocationLine location) } } + /// + /// Computes the area of an object in a Host element + /// + /// + /// + /// + public double GetAreaOfHostedElement(DB.FamilyInstance hostedElement, Wall host) + { + XYZ basisY = XYZ.BasisY; + CurveLoop curveLoop = IFC.ExporterIFCUtils.GetInstanceCutoutFromWall( + host.Document, + host, + hostedElement, + out basisY + ); + IList loops = new List(1); + loops.Add(curveLoop); + double area = IFC.ExporterIFCUtils.ComputeAreaOfCurveLoops(loops); + return area; + } + #region materials public RenderMaterial? GetElementRenderMaterial(DB.Element? element) {