fix: adds built in category for setting ds cat on receive reliably

note: this is not backwards compatible
This commit is contained in:
Dimitrie Stefanescu
2024-11-06 18:33:11 +00:00
parent a1ff69502a
commit 8a0c9d0128
2 changed files with 4 additions and 2 deletions
@@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging;
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 class RevitRootToSpeckleConverter : IRootToSpeckleConverter
if (target is not DB.DirectShape)
{
result["category"] = element.Category?.Name;
result["builtinCategory"] = element.Category?.GetBuiltInCategory().ToString();
}
try
@@ -29,11 +29,11 @@ public class LocalToGlobalToDirectShapeConverter
public DB.DirectShape Convert((Base atomicObject, List<Matrix4x4> 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);