From 3defd285e9b61b0b93ec7077f3098a5646eb5554 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Wed, 11 Dec 2024 22:12:09 +0000 Subject: [PATCH 1/6] feat: fixes issue, WIP local dependencies i will remove them --- .../Speckle.Converters.Revit2024.csproj | 6 ++++++ .../Speckle.Converters.Revit2025.csproj | 6 ++++++ .../Helpers/DisplayValueExtractor.cs | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Converters/Revit/Speckle.Converters.Revit2024/Speckle.Converters.Revit2024.csproj b/Converters/Revit/Speckle.Converters.Revit2024/Speckle.Converters.Revit2024.csproj index a724778fc..6fd6ed549 100644 --- a/Converters/Revit/Speckle.Converters.Revit2024/Speckle.Converters.Revit2024.csproj +++ b/Converters/Revit/Speckle.Converters.Revit2024/Speckle.Converters.Revit2024.csproj @@ -17,4 +17,10 @@ + + + ..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2024\RevitAPISteel.dll + + + diff --git a/Converters/Revit/Speckle.Converters.Revit2025/Speckle.Converters.Revit2025.csproj b/Converters/Revit/Speckle.Converters.Revit2025/Speckle.Converters.Revit2025.csproj index 7e4b59008..325c3498b 100644 --- a/Converters/Revit/Speckle.Converters.Revit2025/Speckle.Converters.Revit2025.csproj +++ b/Converters/Revit/Speckle.Converters.Revit2025/Speckle.Converters.Revit2025.csproj @@ -17,4 +17,10 @@ + + + ..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2025\RevitAPISteel.dll + + + diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 20f840dbc..16836c299 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -4,6 +4,9 @@ using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Settings; using Speckle.Sdk.Common; +#if REVIT2024_OR_GREATER +using Autodesk.Revit.DB.Steel; +#endif namespace Speckle.Converters.RevitShared.Helpers; @@ -120,6 +123,18 @@ element.Category is not null try { geom = element.get_Geometry(options); + +#if REVIT2024_OR_GREATER + // NOTE: incomplete solution. https://forums.autodesk.com/t5/revit-api-forum/how-to-get-steelproxyelement-geometry/td-p/10347898 + // If steel element proxies will be sucked in via category selection, and they are not visible in the current view, they will not be extracted out. + // I'm inclined to go with this as a semi-permanent limitation. + // https://speckle.community/t/revit-2025-2-missing-elements-and-colors/14073 + if (element is SteelProxyElement && geom is null) + { + options = new DB.Options() { View = _converterSettings.Current.Document?.ActiveView }; + geom = element.get_Geometry(options); + } +#endif } // POC: should we be trying to continue? catch (Autodesk.Revit.Exceptions.ArgumentException) @@ -131,7 +146,7 @@ element.Category is not null var solids = new List(); var meshes = new List(); - if (geom != null) + if (geom != null && geom.Any()) { // retrieves all meshes and solids from a geometry element SortGeometry(element, solids, meshes, geom); From b47dea38e5696f4e2d51350a7fe64e77183ab225 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Wed, 11 Dec 2024 22:27:08 +0000 Subject: [PATCH 2/6] feat: relies on built in categories rather than casting (possibly less reliable?) and removes local dependency refs --- .../Speckle.Converters.Revit2024.csproj | 6 ----- .../Speckle.Converters.Revit2025.csproj | 6 ----- .../Helpers/DisplayValueExtractor.cs | 23 ++++++++++++------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Converters/Revit/Speckle.Converters.Revit2024/Speckle.Converters.Revit2024.csproj b/Converters/Revit/Speckle.Converters.Revit2024/Speckle.Converters.Revit2024.csproj index 6fd6ed549..a724778fc 100644 --- a/Converters/Revit/Speckle.Converters.Revit2024/Speckle.Converters.Revit2024.csproj +++ b/Converters/Revit/Speckle.Converters.Revit2024/Speckle.Converters.Revit2024.csproj @@ -17,10 +17,4 @@ - - - ..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2024\RevitAPISteel.dll - - - diff --git a/Converters/Revit/Speckle.Converters.Revit2025/Speckle.Converters.Revit2025.csproj b/Converters/Revit/Speckle.Converters.Revit2025/Speckle.Converters.Revit2025.csproj index 325c3498b..7e4b59008 100644 --- a/Converters/Revit/Speckle.Converters.Revit2025/Speckle.Converters.Revit2025.csproj +++ b/Converters/Revit/Speckle.Converters.Revit2025/Speckle.Converters.Revit2025.csproj @@ -17,10 +17,4 @@ - - - ..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2025\RevitAPISteel.dll - - - diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 16836c299..fd4a04ddd 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -4,9 +4,6 @@ using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Settings; using Speckle.Sdk.Common; -#if REVIT2024_OR_GREATER -using Autodesk.Revit.DB.Steel; -#endif namespace Speckle.Converters.RevitShared.Helpers; @@ -104,12 +101,13 @@ IConverterSettingsStore converterSettings // 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). + var elementBuiltInCategory = element.Category.GetBuiltInCategory(); if ( element.Category is not null && ( - element.Category.GetBuiltInCategory() == DB.BuiltInCategory.OST_PipeFitting - || element.Category.GetBuiltInCategory() == DB.BuiltInCategory.OST_PipeAccessory - || element.Category.GetBuiltInCategory() == 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. #endif @@ -129,9 +127,18 @@ element.Category is not null // If steel element proxies will be sucked in via category selection, and they are not visible in the current view, they will not be extracted out. // I'm inclined to go with this as a semi-permanent limitation. // https://speckle.community/t/revit-2025-2-missing-elements-and-colors/14073 - if (element is SteelProxyElement && geom is null) + if ( + geom is null + && ( + elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnections + || elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnectionPlates + || elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnectionBolts + || elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnectionWelds + || elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnectionShearStuds + ) + ) { - options = new DB.Options() { View = _converterSettings.Current.Document?.ActiveView }; + options = new DB.Options() { View = _converterSettings.Current.Document?.ActiveView }; // NOTE: in case it's a view filter, it should use that specific view! geom = element.get_Geometry(options); } #endif From 7f179fc2af0b1f1aecf56566e9adea4842c8fb0d Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 12 Dec 2024 19:08:49 +0000 Subject: [PATCH 3/6] feat: adds columns and framing to escaped elements reason: joined up beams would export wrong geometry --- .../Helpers/DisplayValueExtractor.cs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index fd4a04ddd..8278a51dc 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -122,26 +122,25 @@ element.Category is not null { geom = element.get_Geometry(options); -#if REVIT2024_OR_GREATER // NOTE: incomplete solution. https://forums.autodesk.com/t5/revit-api-forum/how-to-get-steelproxyelement-geometry/td-p/10347898 // If steel element proxies will be sucked in via category selection, and they are not visible in the current view, they will not be extracted out. // I'm inclined to go with this as a semi-permanent limitation. // https://speckle.community/t/revit-2025-2-missing-elements-and-colors/14073 if ( - geom is null - && ( - elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnections - || elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnectionPlates - || elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnectionBolts - || elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnectionWelds - || elementBuiltInCategory == DB.BuiltInCategory.OST_StructConnectionShearStuds - ) + (geom is null || !geom.Any()) + && elementBuiltInCategory + is DB.BuiltInCategory.OST_StructConnections + or DB.BuiltInCategory.OST_StructConnectionPlates + or DB.BuiltInCategory.OST_StructuralFraming + or DB.BuiltInCategory.OST_StructuralColumns + or DB.BuiltInCategory.OST_StructConnectionBolts + or DB.BuiltInCategory.OST_StructConnectionWelds + or DB.BuiltInCategory.OST_StructConnectionShearStuds ) { - options = new DB.Options() { View = _converterSettings.Current.Document?.ActiveView }; // NOTE: in case it's a view filter, it should use that specific view! + options = new DB.Options() { View = _converterSettings.Current.Document.NotNull().ActiveView }; // TODO/NOTE: in case it's a view filter, it should use that specific view. This is a limiting partial fix. geom = element.get_Geometry(options); } -#endif } // POC: should we be trying to continue? catch (Autodesk.Revit.Exceptions.ArgumentException) From e2423700eaefed597a67f4243e4608de69d67179 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 12 Dec 2024 19:23:33 +0000 Subject: [PATCH 4/6] formatting --- .../Helpers/DisplayValueExtractor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index cfffce120..8278a51dc 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -121,7 +121,7 @@ element.Category is not null try { geom = element.get_Geometry(options); - + // NOTE: incomplete solution. https://forums.autodesk.com/t5/revit-api-forum/how-to-get-steelproxyelement-geometry/td-p/10347898 // If steel element proxies will be sucked in via category selection, and they are not visible in the current view, they will not be extracted out. // I'm inclined to go with this as a semi-permanent limitation. From 0d0331ca2fa7046498e1d01c316894cf72013b4b Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 12 Dec 2024 19:48:00 +0000 Subject: [PATCH 5/6] cleanup: extracts view options override logic into one place --- .../Helpers/DisplayValueExtractor.cs | 86 +++++++++++-------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 8278a51dc..16209207b 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -98,49 +98,12 @@ IConverterSettingsStore converterSettings { //options = ViewSpecificOptions ?? options ?? new Options() { DetailLevel = DetailLevelSetting }; options ??= new DB.Options { DetailLevel = _detailLevelMap[_converterSettings.Current.DetailLevel] }; - - // 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). - var elementBuiltInCategory = element.Category.GetBuiltInCategory(); - if ( - element.Category is not null - && ( - 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. -#endif - ) - ) - { - options.DetailLevel = DB.ViewDetailLevel.Fine; - } + options = OverrideViewOptions(element, options); DB.GeometryElement geom; try { geom = element.get_Geometry(options); - - // NOTE: incomplete solution. https://forums.autodesk.com/t5/revit-api-forum/how-to-get-steelproxyelement-geometry/td-p/10347898 - // If steel element proxies will be sucked in via category selection, and they are not visible in the current view, they will not be extracted out. - // I'm inclined to go with this as a semi-permanent limitation. - // https://speckle.community/t/revit-2025-2-missing-elements-and-colors/14073 - if ( - (geom is null || !geom.Any()) - && elementBuiltInCategory - is DB.BuiltInCategory.OST_StructConnections - or DB.BuiltInCategory.OST_StructConnectionPlates - or DB.BuiltInCategory.OST_StructuralFraming - or DB.BuiltInCategory.OST_StructuralColumns - or DB.BuiltInCategory.OST_StructConnectionBolts - or DB.BuiltInCategory.OST_StructConnectionWelds - or DB.BuiltInCategory.OST_StructConnectionShearStuds - ) - { - options = new DB.Options() { View = _converterSettings.Current.Document.NotNull().ActiveView }; // TODO/NOTE: in case it's a view filter, it should use that specific view. This is a limiting partial fix. - geom = element.get_Geometry(options); - } } // POC: should we be trying to continue? catch (Autodesk.Revit.Exceptions.ArgumentException) @@ -269,4 +232,51 @@ private bool ShouldSetElementDisplayToTransparent(DB.Element element) return false; #endif } + + /// + /// Overrides current view options to extract meaningful geometry for various elements. + /// + /// + /// + private DB.Options OverrideViewOptions(DB.Element element, DB.Options 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 +#if REVIT2024_OR_GREATER + || element is DB.Toposolid // note, brought back from 2.x.x. +#endif + ) + ) + { + currentOptions.DetailLevel = DB.ViewDetailLevel.Fine; // Force detail level to be fine + return currentOptions; + } + // NOTE: On steel elements. This is an incomplete solution. + // If steel element proxies will be sucked in via category selection, and they are not visible in the current view, they will not be extracted out. + // I'm inclined to go with this as a semi-permanent limitation. See: + // https://speckle.community/t/revit-2025-2-missing-elements-and-colors/14073 + // and https://forums.autodesk.com/t5/revit-api-forum/how-to-get-steelproxyelement-geometry/td-p/10347898 + if ( + elementBuiltInCategory + is DB.BuiltInCategory.OST_StructConnections + or DB.BuiltInCategory.OST_StructConnectionPlates + or DB.BuiltInCategory.OST_StructuralFraming + or DB.BuiltInCategory.OST_StructuralColumns + or DB.BuiltInCategory.OST_StructConnectionBolts + or DB.BuiltInCategory.OST_StructConnectionWelds + or DB.BuiltInCategory.OST_StructConnectionShearStuds + ) + { + return new DB.Options() { View = _converterSettings.Current.Document.NotNull().ActiveView }; // TODO/NOTE: in case it's a view filter, it should use that specific view. This is a limiting partial fix. + } + return currentOptions; + } } From 8276cf6d603bc01a06d46418cb706e01a591e63c Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 12 Dec 2024 19:49:10 +0000 Subject: [PATCH 6/6] chore: comment --- .../Helpers/DisplayValueExtractor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index 16209207b..52e861a06 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -234,7 +234,7 @@ private bool ShouldSetElementDisplayToTransparent(DB.Element element) } /// - /// Overrides current view options to extract meaningful geometry for various elements. + /// Overrides current view options to extract meaningful geometry for various elements. E.g., pipes, plumbing fixtures, steel elements /// /// ///