From dbefb1b290f234243e130c185a7db229a96a9cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Wed, 8 Jan 2025 21:26:34 +0300 Subject: [PATCH] Null check before attempt to override view options (#474) --- .../Helpers/DisplayValueExtractor.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 52e861a06..406903982 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -240,20 +240,23 @@ private bool ShouldSetElementDisplayToTransparent(DB.Element element) /// private DB.Options OverrideViewOptions(DB.Element element, DB.Options currentOptions) { + // there is no point to progress if element category already null + if (element.Category is null) + { + return currentOptions; + } + var elementBuiltInCategory = element.Category.GetBuiltInCategory(); // Note: some elements do not get display values (you get invalid solids) unless we force the view detail level to be fine. This is annoying, but it's bad ux: people think the // elements are not there (they are, just invisible). if ( - element.Category is not null - && ( - elementBuiltInCategory == DB.BuiltInCategory.OST_PipeFitting - || elementBuiltInCategory == DB.BuiltInCategory.OST_PipeAccessory - || elementBuiltInCategory == DB.BuiltInCategory.OST_PlumbingFixtures + elementBuiltInCategory == DB.BuiltInCategory.OST_PipeFitting + || elementBuiltInCategory == DB.BuiltInCategory.OST_PipeAccessory + || elementBuiltInCategory == DB.BuiltInCategory.OST_PlumbingFixtures #if REVIT2024_OR_GREATER - || element is DB.Toposolid // note, brought back from 2.x.x. + || element is DB.Toposolid // note, brought back from 2.x.x. #endif - ) ) { currentOptions.DetailLevel = DB.ViewDetailLevel.Fine; // Force detail level to be fine