From edebc8e98f661d566e86eafff89f6d90a16632fd Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 18 Sep 2025 10:42:45 +0100 Subject: [PATCH] Remove Revit file entity check as we're storing model card state only in DB and not the file (#1100) --- .../RevitConnectorModule.cs | 1 - .../HostApp/DocumentModelStorageSchema.cs | 22 ----------- .../HostApp/RevitDocumentStore.cs | 39 ++----------------- .../Speckle.Connectors.RevitShared.projitems | 1 - 4 files changed, 4 insertions(+), 59 deletions(-) delete mode 100644 Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs diff --git a/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index 7a7aa35d6..a84ec0ad0 100644 --- a/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -37,7 +37,6 @@ public static class ServiceRegistration serviceCollection.AddMatchingInterfacesAsTransient(Assembly.GetExecutingAssembly()); // Storage Schema - serviceCollection.AddScoped(); serviceCollection.AddScoped(); // POC: we need to review the scopes and create a document on what the policy is diff --git a/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs b/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs deleted file mode 100644 index ded698f75..000000000 --- a/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/DocumentModelStorageSchema.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Autodesk.Revit.DB.ExtensibleStorage; - -namespace Speckle.Connectors.Revit.HostApp; - -public class DocumentModelStorageSchema : IStorageSchema -{ - private readonly Guid _schemaGuid = new("D690F2B4-BDB0-4CB4-8657-17844ADF42AA"); - - public Schema GetSchema() - { - Schema schema = Schema.Lookup(_schemaGuid); - if (schema != null) - { - return schema; - } - - using SchemaBuilder builder = new(_schemaGuid); - builder.SetSchemaName("DUI3State"); - builder.AddSimpleField("contents", typeof(string)); - return builder.Finish(); - } -} diff --git a/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs b/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs index 8fef29774..f18779ffd 100644 --- a/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs +++ b/Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/RevitDocumentStore.cs @@ -1,5 +1,4 @@ using Autodesk.Revit.DB; -using Autodesk.Revit.DB.ExtensibleStorage; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; using Microsoft.Extensions.Logging; @@ -20,7 +19,6 @@ internal sealed class RevitDocumentStore : DocumentModelStore private readonly ILogger _logger; private readonly IAppIdleManager _idleManager; private readonly RevitContext _revitContext; - private readonly DocumentModelStorageSchema _documentModelStorageSchema; private readonly ITopLevelExceptionHandler _topLevelExceptionHandler; private readonly ISqLiteJsonCacheManager _jsonCacheManager; @@ -28,7 +26,6 @@ internal sealed class RevitDocumentStore : DocumentModelStore IAppIdleManager idleManager, RevitContext revitContext, IJsonSerializer jsonSerializer, - DocumentModelStorageSchema documentModelStorageSchema, ITopLevelExceptionHandler topLevelExceptionHandler, IRevitTask revitTask, ISqLiteJsonCacheManagerFactory jsonCacheManagerFactory, @@ -39,7 +36,6 @@ internal sealed class RevitDocumentStore : DocumentModelStore _jsonCacheManager = jsonCacheManagerFactory.CreateForUser("ConnectorsFileData"); _idleManager = idleManager; _revitContext = revitContext; - _documentModelStorageSchema = documentModelStorageSchema; _topLevelExceptionHandler = topLevelExceptionHandler; _logger = logger; @@ -131,42 +127,15 @@ internal sealed class RevitDocumentStore : DocumentModelStore return; } - var stateEntity = GetSpeckleEntity(document); - if (stateEntity == null || !stateEntity.IsValid()) - { - ClearAndSave(); - return; - } - var key = GetKeyForDocument(document); if (key != null) { var state = _jsonCacheManager.GetObject(key); + if (state == null) + { + return; + } LoadFromString(state); } } - - private Entity? GetSpeckleEntity(Document? doc) - { - if (doc is null) - { - return null; - } - using FilteredElementCollector collector = new(doc); - - FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage)); - foreach (Element element in dataStorages) - { - DataStorage dataStorage = (DataStorage)element; - Entity settingEntity = dataStorage.GetEntity(_documentModelStorageSchema.GetSchema()); - if (!settingEntity.IsValid()) - { - continue; - } - - return settingEntity; - } - - return null; - } } diff --git a/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index 152177cfc..dcc8767a6 100644 --- a/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -19,7 +19,6 @@ -