diff --git a/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/ElementUnpacker.cs b/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/ElementUnpacker.cs index f78622879..babb9cd20 100644 --- a/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/ElementUnpacker.cs +++ b/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/ElementUnpacker.cs @@ -61,7 +61,9 @@ public class ElementUnpacker // We add null checks to handle cases where elements can't be properly resolved // POC: this might screw up generating hosting rel generation here, because nested families in groups get flattened out by GetMemberIds(). var groupElements = g.GetMemberIds().Select(doc.GetElement).Where(el => el != null); - unpackedElements.AddRange(UnpackElements(groupElements, doc)); + // GetMemberIds returns a bunch of noise (sketch lines, form elements etc.) below filter, filters out those noise. + var filteredElements = FilterGroupElements(groupElements); + unpackedElements.AddRange(UnpackElements(filteredElements, doc)); } else if (element is BaseArray baseArray) { @@ -106,6 +108,34 @@ public class ElementUnpacker return unpackedElements.Where(el => el != null).GroupBy(el => el.Id).Select(g => g.First()).ToList(); // no disinctBy in here sadly. } + /// + /// Filters out elements that should not be sent from groups: + /// - Elements whose category parent is OST_Mass or OST_Lines (these are typically construction geometry) + /// - FamilySymbol elements (type definitions rather than placed instances) + /// + private IEnumerable FilterGroupElements(IEnumerable elements) + { + foreach (var element in elements) + { + if (element is FamilySymbol) + { + continue; + } + + var category = element.Category; + if (category?.Parent != null) + { + var parentBuiltInCategory = category.Parent.GetBuiltInCategory(); + if (parentBuiltInCategory == BuiltInCategory.OST_Mass || parentBuiltInCategory == BuiltInCategory.OST_Lines) + { + continue; + } + } + + yield return element; + } + } + // We use the nullable document (happiness level 5/10) for the sake of linked models - bc we use this function in 2 different places // 1- RootObjectBuilder with linked model document - otherwise we cannot unpack elements from correct document. // 2- Evicting the cache while introducing the settings