diff --git a/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISLayerUnpacker.cs b/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISLayerUnpacker.cs index 7f68b03d..3db6653e 100644 --- a/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISLayerUnpacker.cs +++ b/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/HostApp/ArcGISLayerUnpacker.cs @@ -37,7 +37,7 @@ public class ArcGISLayerUnpacker Collection containerCollection = CreateAndCacheMapMemberCollection(mapMember, true); parentCollection.elements.Add(containerCollection); - UnpackSelection(container.Layers, containerCollection, objects); + UnpackSelection(container.Layers, containerCollection, objects); break; default: diff --git a/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/ArcGISRootObjectBuilder.cs b/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/ArcGISRootObjectBuilder.cs index 51bd4eaf..aae2c1c2 100644 --- a/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/ArcGISRootObjectBuilder.cs +++ b/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/ArcGISRootObjectBuilder.cs @@ -102,7 +102,7 @@ CancellationToken cancellationToken IEnumerable layersOrdered = _mapMemberUtils.GetMapMembersInOrder(map, layers); using (var _ = _activityFactory.Start("Unpacking selection")) { - unpackedLayers = _layerUnpacker.UnpackSelection(layersOrdered, rootCollection); + unpackedLayers = _layerUnpacker.UnpackSelection(layersOrdered, rootCollection); } List results = new(unpackedLayers.Count); @@ -112,7 +112,7 @@ CancellationToken cancellationToken int count = 0; foreach (ADM.MapMember layer in unpackedLayers) { - cancellationToken.ThrowIfCancellationRequested(); + cancellationToken.ThrowIfCancellationRequested(); string layerApplicationId = layer.GetSpeckleApplicationId(); try @@ -138,15 +138,15 @@ out ObjectReference? value switch (layer) { case ADM.FeatureLayer featureLayer: - List convertedFeatureLayerObjects = ConvertFeatureLayerObjects(featureLayer); + List convertedFeatureLayerObjects = ConvertFeatureLayerObjects(featureLayer); layerCollection.elements.AddRange(convertedFeatureLayerObjects); break; case ADM.RasterLayer rasterLayer: - List convertedRasterLayerObjects = ConvertRasterLayerObjects(rasterLayer); + List convertedRasterLayerObjects = ConvertRasterLayerObjects(rasterLayer); layerCollection.elements.AddRange(convertedRasterLayerObjects); break; case ADM.LasDatasetLayer lasDatasetLayer: - List convertedLasDatasetObjects = ConvertLasDatasetLayerObjects(lasDatasetLayer); + List convertedLasDatasetObjects = ConvertLasDatasetLayerObjects(lasDatasetLayer); layerCollection.elements.AddRange(convertedLasDatasetObjects); break; default: @@ -189,32 +189,31 @@ private List ConvertFeatureLayerObjects(ADM.FeatureLayer featureLayer) { string layerApplicationId = featureLayer.GetSpeckleApplicationId(); List convertedObjects = new(); - // store the layer renderer for color unpacking - _colorUnpacker.StoreRendererAndFields(featureLayer); + // store the layer renderer for color unpacking + _colorUnpacker.StoreRendererAndFields(featureLayer); - // search the rows of the layer, where each row is treated like an object - // RowCursor is IDisposable but is not being correctly picked up by IDE warnings. - // This means we need to be carefully adding using statements based on the API documentation coming from each method/class - using (ACD.RowCursor rowCursor = featureLayer.Search()) + // search the rows of the layer, where each row is treated like an object + // RowCursor is IDisposable but is not being correctly picked up by IDE warnings. + // This means we need to be carefully adding using statements based on the API documentation coming from each method/class + using (ACD.RowCursor rowCursor = featureLayer.Search()) + { + while (rowCursor.MoveNext()) + { + // Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller. + using (ACD.Row row = rowCursor.Current) { - while (rowCursor.MoveNext()) - { - // Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller. - using (ACD.Row row = rowCursor.Current) - { - // get application id. test for subtypes before defaulting to base type. - Base converted = _rootToSpeckleConverter.Convert(row); - string applicationId = row.GetSpeckleApplicationId(layerApplicationId); - converted.applicationId = applicationId; + // get application id. test for subtypes before defaulting to base type. + Base converted = _rootToSpeckleConverter.Convert(row); + string applicationId = row.GetSpeckleApplicationId(layerApplicationId); + converted.applicationId = applicationId; - convertedObjects.Add(converted); + convertedObjects.Add(converted); - // process the object color - _colorUnpacker.ProcessFeatureLayerColor(row, applicationId); - } - } + // process the object color + _colorUnpacker.ProcessFeatureLayerColor(row, applicationId); } - + } + } return convertedObjects; } @@ -224,11 +223,11 @@ private List ConvertRasterLayerObjects(ADM.RasterLayer rasterLayer) { string layerApplicationId = rasterLayer.GetSpeckleApplicationId(); List convertedObjects = new(); - Raster raster = rasterLayer.GetRaster(); - Base converted = _rootToSpeckleConverter.Convert(raster); - string applicationId = raster.GetSpeckleApplicationId(layerApplicationId); - converted.applicationId = applicationId; - convertedObjects.Add(converted); + Raster raster = rasterLayer.GetRaster(); + Base converted = _rootToSpeckleConverter.Convert(raster); + string applicationId = raster.GetSpeckleApplicationId(layerApplicationId); + converted.applicationId = applicationId; + convertedObjects.Add(converted); return convertedObjects; } @@ -239,27 +238,25 @@ private List ConvertLasDatasetLayerObjects(ADM.LasDatasetLayer lasDatasetL try { - // store the layer renderer for color unpacking - _colorUnpacker.StoreRenderer(lasDatasetLayer); + // store the layer renderer for color unpacking + _colorUnpacker.StoreRenderer(lasDatasetLayer); - using ( - ACD.Analyst3D.LasPointCursor ptCursor = lasDatasetLayer.SearchPoints(new ACD.Analyst3D.LasPointFilter()) - ) + using (ACD.Analyst3D.LasPointCursor ptCursor = lasDatasetLayer.SearchPoints(new ACD.Analyst3D.LasPointFilter())) + { + while (ptCursor.MoveNext()) + { + using (ACD.Analyst3D.LasPoint pt = ptCursor.Current) { - while (ptCursor.MoveNext()) - { - using (ACD.Analyst3D.LasPoint pt = ptCursor.Current) - { - Base converted = _rootToSpeckleConverter.Convert(pt); - string applicationId = pt.GetSpeckleApplicationId(layerApplicationId); - converted.applicationId = applicationId; - convertedObjects.Add(converted); + Base converted = _rootToSpeckleConverter.Convert(pt); + string applicationId = pt.GetSpeckleApplicationId(layerApplicationId); + converted.applicationId = applicationId; + convertedObjects.Add(converted); - // process the object color - _colorUnpacker.ProcessLasLayerColor(pt, applicationId); - } - } + // process the object color + _colorUnpacker.ProcessLasLayerColor(pt, applicationId); } + } + } } catch (ACD.Exceptions.TinException ex) { diff --git a/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/Bindings/NavisworksBasicConnectorBinding.cs b/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/Bindings/NavisworksBasicConnectorBinding.cs index 6ad747f1..fa81d8e5 100644 --- a/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/Bindings/NavisworksBasicConnectorBinding.cs +++ b/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/Bindings/NavisworksBasicConnectorBinding.cs @@ -41,17 +41,14 @@ NavisworksDocumentEvents documentEvents public string GetConnectorVersion() => _speckleApplication.SpeckleVersion; - public DocumentInfo? GetDocumentInfo() - => - NavisworksApp.ActiveDocument is null || NavisworksApp.ActiveDocument.Models.Count == 0 - ? null - : new DocumentInfo( - NavisworksApp.ActiveDocument.CurrentFileName, - NavisworksApp.ActiveDocument.Title, - NavisworksApp.ActiveDocument.GetHashCode().ToString() - ) - - ; + public DocumentInfo? GetDocumentInfo() => + NavisworksApp.ActiveDocument is null || NavisworksApp.ActiveDocument.Models.Count == 0 + ? null + : new DocumentInfo( + NavisworksApp.ActiveDocument.CurrentFileName, + NavisworksApp.ActiveDocument.Title, + NavisworksApp.ActiveDocument.GetHashCode().ToString() + ); public DocumentModelStore GetDocumentState() => _store; @@ -64,6 +61,6 @@ NavisworksDocumentEvents documentEvents public Task HighlightModel(string modelCardId) => Task.CompletedTask; public async Task HighlightObjects(IReadOnlyList objectIds) => - // TODO: Implement highlighting logic on main thread - await Task.CompletedTask.ConfigureAwait(false); + // TODO: Implement highlighting logic on main thread + await Task.CompletedTask.ConfigureAwait(false); } diff --git a/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/Bindings/NavisworksSendBinding.cs b/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/Bindings/NavisworksSendBinding.cs index ee9bb0fc..0d74a9f9 100644 --- a/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/Bindings/NavisworksSendBinding.cs +++ b/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/Bindings/NavisworksSendBinding.cs @@ -87,22 +87,21 @@ public async Task Send(string modelCardId) using var activity = _activityFactory.Start(); try { - var modelCard = GetModelCard(modelCardId); + var modelCard = GetModelCard(modelCardId); - using var scope = _serviceProvider.CreateScope(); + using var scope = _serviceProvider.CreateScope(); - InitializeConverterSettings(scope, modelCard); + InitializeConverterSettings(scope, modelCard); - CancellationToken token = _cancellationManager.InitCancellationTokenSource(modelCardId); + CancellationToken token = _cancellationManager.InitCancellationTokenSource(modelCardId); - var navisworksModelItems = GetNavisworksModelItems(modelCard); + var navisworksModelItems = GetNavisworksModelItems(modelCard); - var sendResult = await ExecuteSendOperation(scope, modelCard, navisworksModelItems, token) - .ConfigureAwait(false); + var sendResult = await ExecuteSendOperation(scope, modelCard, navisworksModelItems, token).ConfigureAwait(false); - await Commands - .SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults) - .ConfigureAwait(false); + await Commands + .SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults) + .ConfigureAwait(false); } catch (OperationCanceledException) { diff --git a/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/HostApp/NavisworksDocumentEvents.cs b/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/HostApp/NavisworksDocumentEvents.cs index db87e7e0..5f4cadc6 100644 --- a/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/HostApp/NavisworksDocumentEvents.cs +++ b/Connectors/Navisworks/Speckle.Connectors.NavisworksShared/HostApp/NavisworksDocumentEvents.cs @@ -102,24 +102,24 @@ private async Task ProcessModelStateChangeAsync() try { - var store = _serviceProvider.GetRequiredService(); - var basicBinding = _serviceProvider.GetRequiredService(); - var commands = (basicBinding as NavisworksBasicConnectorBinding)?.Commands; - - switch (_finalModelCount) - { - case 0 when _priorModelCount > 0: - store.ClearAndSave(); - break; - case > 0 when _priorModelCount == 0: - store.ReloadState(); - break; - } - - if (commands != null) - { - await commands.NotifyDocumentChanged().ConfigureAwait(false); - } + var store = _serviceProvider.GetRequiredService(); + var basicBinding = _serviceProvider.GetRequiredService(); + var commands = (basicBinding as NavisworksBasicConnectorBinding)?.Commands; + + switch (_finalModelCount) + { + case 0 when _priorModelCount > 0: + store.ClearAndSave(); + break; + case > 0 when _priorModelCount == 0: + store.ReloadState(); + break; + } + + if (commands != null) + { + await commands.NotifyDocumentChanged().ConfigureAwait(false); + } } finally {