diff --git a/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToSpeckleConverter.cs b/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToSpeckleConverter.cs index cc112060f..4d74554b2 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToSpeckleConverter.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToSpeckleConverter.cs @@ -3,6 +3,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Converters.Common.Registration; +using Speckle.Converters.RevitShared.Extensions; using Speckle.Converters.RevitShared.Settings; using Speckle.Converters.RevitShared.ToSpeckle; using Speckle.Sdk; @@ -58,6 +59,7 @@ public Base Convert(object target) if (target is not DB.DirectShape) { result["category"] = element.Category?.Name; + result["builtinCategory"] = element.Category?.GetBuiltInCategory().ToString(); } try 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/ToHost/Raw/LocalToGlobalToDirectShapeConverter.cs b/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/LocalToGlobalToDirectShapeConverter.cs index c33972225..840e9e999 100644 --- a/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/LocalToGlobalToDirectShapeConverter.cs +++ b/Converters/Revit/Speckle.Converters.RevitShared/ToHost/Raw/LocalToGlobalToDirectShapeConverter.cs @@ -29,11 +29,11 @@ public LocalToGlobalToDirectShapeConverter( public DB.DirectShape Convert((Base atomicObject, List matrix) target) { // 1- set ds category - var category = target.atomicObject["category"] as string; + var category = target.atomicObject["builtinCategory"] as string; var dsCategory = DB.BuiltInCategory.OST_GenericModel; if (category is not null) { - var res = Enum.TryParse($"OST_{category}", out DB.BuiltInCategory cat); + var res = Enum.TryParse(category, out DB.BuiltInCategory cat); if (res) { var c = DB.Category.GetCategory(_converterSettings.Current.Document, cat); 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; + } +}