diff --git a/src/RvtIO/Ifc/IfcExporter.cs b/src/RvtIO/Ifc/IfcExporter.cs index 6f62812f..8a4c9710 100644 --- a/src/RvtIO/Ifc/IfcExporter.cs +++ b/src/RvtIO/Ifc/IfcExporter.cs @@ -4646,7 +4646,8 @@ fallbackSourceOwnerTagId is null elemPlacementId = w.Add("IFCLOCALPLACEMENT", $"{R(elemStoreyPlacementId)},{R(rampAxisId > 0 ? rampAxisId : axisId)}"); withFaces++; } - else if (ifcType is "IFCWALLSTANDARDCASE" or "IFCWALL") + else if (ifcType is "IFCWALLSTANDARDCASE" or "IFCWALL" + && !ProductRules.IsGeometrylessUnresolvedWall(elem)) { // Walls: SweptSolid with profile from bottom face or GeoSolid (shapeId, elemPlacementId) = CreateWallSweptSolid( diff --git a/src/RvtIO/Model/ProductRules.cs b/src/RvtIO/Model/ProductRules.cs index e0292af5..fef8996e 100644 --- a/src/RvtIO/Model/ProductRules.cs +++ b/src/RvtIO/Model/ProductRules.cs @@ -95,6 +95,12 @@ internal static bool IsValidatedStackedWallContainer( && type.Id == element.FamilyTypeId && type.CategoryId == -2003500 && type.IsSerializedStackedWallType; + /// A wall whose own geometry carries no decoded faces or BRep solids, no location curve, and only an unresolved or unexpanded symbol placement. + internal static bool IsGeometrylessUnresolvedWall(Element element) => + element.Location is not { CurveType: "Line" or "Arc" } + && element.Geometry is { Faces.Count: 0, BrepSolids: not { Count: > 0 } } geometry + && (geometry.UnresolvedSymbol || geometry.Instances is { Count: > 0 }); + /// The last project phase of the authored phase order that is a phase element of the document, null when there is none. internal static int? LastProjectPhase(RevitFileInfo info) { diff --git a/src/RvtIO/Parsing/ElementBuilder.cs b/src/RvtIO/Parsing/ElementBuilder.cs index 37a062c0..bf7b6c60 100644 --- a/src/RvtIO/Parsing/ElementBuilder.cs +++ b/src/RvtIO/Parsing/ElementBuilder.cs @@ -8479,11 +8479,11 @@ InheritedTypeParameter Describe(uint id) /// Compute extruded solid geometry for wall elements. Uses world-coordinate GRep face data when /// available (the largest vertical face gives wall direction, position, length, and height). /// - private static void ComputeWallSolids(List elements) + internal static void ComputeWallSolids(List elements) { foreach (var elem in elements) { - if (elem.Category != "OST_Walls") continue; + if (elem.Category != "OST_Walls" || ProductRules.IsGeometrylessUnresolvedWall(elem)) continue; double[]? bbox = elem.BoundingBox ?? elem.Geometry?.BoundingBox; if (bbox == null || bbox.Length < 6) continue; diff --git a/tests/RvtIO.Tests/IfcExporterGeometrylessProductSuppressionTests.cs b/tests/RvtIO.Tests/IfcExporterGeometrylessProductSuppressionTests.cs index 18312306..729432d5 100644 --- a/tests/RvtIO.Tests/IfcExporterGeometrylessProductSuppressionTests.cs +++ b/tests/RvtIO.Tests/IfcExporterGeometrylessProductSuppressionTests.cs @@ -1,5 +1,7 @@ using RvtIO.Ifc; +using RvtIO.Meshes; using RvtIO.Model; +using RvtIO.Parsing; using System.Text.RegularExpressions; using Xunit; @@ -958,6 +960,76 @@ private static GeometryData SolidPrism() }).ToList(), }; + [Theory] + [InlineData(IfcProfile.Current)] + [InlineData(IfcProfile.Legacy)] + public void WallWithUnresolvedSymbolAndNoFaces_GetsNoSolid_IsNoGeometry_AndIsSuppressed(IfcProfile profile) + { + var wall = new Element + { + Id = 350, + TypeId = 351, + CategoryId = -2000011, + Category = "OST_Walls", + Name = "VoidInPlaceWall", + References = [3], + Parameters = + [ + PhaseParameter(), + new Parameter { Id = -1002050, StorageType = StorageType.ElementId, Value = 351 }, + new Parameter { Id = -1001000, Definition = new Definition { Name = "WALL_ATTR_WIDTH_PARAM" }, StorageType = StorageType.Double, Value = 1.0 }, + ], + BoundingBox = [0, 0, 0, 10, 4, 8], + Geometry = new GeometryData + { + BoundingBox = [0, 0, 0, 10, 4, 8], + UnresolvedSymbol = true, + Instances = + [ + new GeoInstance + { + SymbolId = 351, + Transform = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], + }, + ], + }, + }; + var symbol = new Element + { + Id = 351, + CategoryId = -2000011, + Category = "OST_Walls", + Name = "VoidInPlaceWall", + BoundingBox = [0, 0, 0, 10, 4, 8], + }; + var info = new RevitFileInfo { Elements = [wall, symbol] }; + ElementBuilder.ComputeWallSolids(info.Elements); + + Assert.Null(wall.Geometry.Solids); + + var mesh = Assert.Single(ElementMeshes.Extract(RvtDocument.FromInfo(info)).Elements); + Assert.Equal(wall.Id, mesh.ElementId); + Assert.Equal(MeshCoverage.NoGeometry, mesh.Coverage); + + string path = TempIfcPath($"wall-unresolved-{profile}"); + try + { + var diagnostics = new StringWriter(); + var skipLog = new SkipLog(); + new IfcExporter(diagnostics) { Profile = profile, SkipLog = skipLog }.Export(info, path); + string ifc = File.ReadAllText(path); + + Assert.DoesNotContain("=IFCWALL(", ifc); + Assert.DoesNotContain("=IFCWALLSTANDARDCASE(", ifc); + Assert.DoesNotContain("=IFCEXTRUDEDAREASOLID(", ifc); + Assert.DoesNotContain("Pset_QuantityTakeOff", ifc); + Assert.Empty(Regex.Matches(ifc, @"#\d+=IFCRELCONTAINEDINSPATIALSTRUCTURE\(")); + Assert.Contains(skipLog.Groups(), group => group.Reason == "geometryless-product" && group.Examples.Contains(wall.Id)); + Assert.Contains("IFC geometry-less element products suppressed: 1 - IFCWALL=1", diagnostics.ToString()); + } + finally { Cleanup(path); } + } + private static string TempIfcPath(string tag) => Path.Combine(Path.GetTempPath(), $"revitreader-{tag}-{Guid.NewGuid():N}.ifc");