From f6e4fcd2d08482a2276734a5fc2351872da3f6d4 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Wed, 6 Nov 2024 19:26:14 +0000 Subject: [PATCH] feat: adds top level converter for railings and fixes a different bug --- .../Speckle.Converters.RevitShared.projitems | 1 + .../ElementTopLevelConverterToSpeckle.cs | 2 +- .../RailingTopLevelConverterToSpeckle.cs | 49 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/RailingTopLevelConverterToSpeckle.cs diff --git a/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index a217201e3..56045cddb 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -89,6 +89,7 @@ + diff --git a/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ElementTopLevelConverterToSpeckle.cs b/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ElementTopLevelConverterToSpeckle.cs index ba70f6c99..cb38a7464 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ElementTopLevelConverterToSpeckle.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/ElementTopLevelConverterToSpeckle.cs @@ -27,7 +27,7 @@ public override RevitElement Convert(DB.Element target) ? symbol.FamilyName : "no family"; string category = target.Category?.Name ?? "no category"; - List displayValue = _displayValueExtractor.GetDisplayValue(target); + List displayValue = _displayValueExtractor.GetDisplayValue(target); RevitElement speckleElement = new() diff --git a/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/RailingTopLevelConverterToSpeckle.cs b/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/RailingTopLevelConverterToSpeckle.cs new file mode 100644 index 000000000..e7f08d676 --- /dev/null +++ b/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopLevel/RailingTopLevelConverterToSpeckle.cs @@ -0,0 +1,49 @@ +using Speckle.Converters.Common; +using Speckle.Converters.RevitShared.Helpers; +using Speckle.Converters.RevitShared.Settings; +using Speckle.Converters.RevitShared.ToSpeckle; + +namespace Speckle.Converters.Revit2023.ToSpeckle.TopLevel; + +[NameAndRankValue(nameof(DBA.Railing), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class RailingTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +{ + private readonly DisplayValueExtractor _displayValueExtractor; + private readonly IConverterSettingsStore _converterSettings; + + public RailingTopLevelConverterToSpeckle( + DisplayValueExtractor displayValueExtractor, + IConverterSettingsStore converterSettings + ) + { + _displayValueExtractor = displayValueExtractor; + _converterSettings = converterSettings; + } + + public override SOBR.RevitElement Convert(DBA.Railing target) + { + string family = target.Document.GetElement(target.GetTypeId()) is DB.FamilySymbol symbol + ? symbol.FamilyName + : "no family"; + string category = target.Category?.Name ?? "no category"; + var displayValue = _displayValueExtractor.GetDisplayValue(target); + + var topRail = _converterSettings.Current.Document.GetElement(target.TopRail); + var topRailDisplayValue = _displayValueExtractor.GetDisplayValue(topRail); + + displayValue.AddRange(topRailDisplayValue); + + SOBR.RevitElement speckleElement = + new() + { + type = target.Name, + category = category, + family = family, + displayValue = displayValue + }; + + speckleElement["units"] = _converterSettings.Current.SpeckleUnits; + + return speckleElement; + } +}